2017-05-10 10:31:17 -04:00
|
|
|
mongoose = require 'mongoose'
|
2014-02-12 05:23:40 -05:00
|
|
|
Settings = require 'settings-sharelatex'
|
2018-05-31 06:54:50 -04:00
|
|
|
TeamInviteSchema = require('./TeamInvite').TeamInviteSchema
|
2014-02-12 05:23:40 -05:00
|
|
|
|
|
|
|
Schema = mongoose.Schema
|
|
|
|
ObjectId = Schema.ObjectId
|
|
|
|
|
|
|
|
SubscriptionSchema = new Schema
|
|
|
|
admin_id : {type:ObjectId, ref:'User', index: {unique: true, dropDups: true}}
|
2018-06-29 06:22:58 -04:00
|
|
|
manager_ids : [ type:ObjectId, ref:'User' ]
|
2017-06-08 07:12:08 -04:00
|
|
|
member_ids : [ type:ObjectId, ref:'User' ]
|
|
|
|
invited_emails: [ String ]
|
2018-05-31 06:54:50 -04:00
|
|
|
teamInvites : [ TeamInviteSchema ]
|
2014-02-12 05:23:40 -05:00
|
|
|
recurlySubscription_id : String
|
2018-07-13 06:11:04 -04:00
|
|
|
teamName : {type: String}
|
2018-11-13 05:33:18 -05:00
|
|
|
teamNotice : {type: String}
|
2014-02-12 05:23:40 -05:00
|
|
|
planCode : {type: String}
|
|
|
|
groupPlan : {type: Boolean, default: false}
|
|
|
|
membersLimit: {type:Number, default:0}
|
2014-10-10 10:57:27 -04:00
|
|
|
customAccount: Boolean
|
2018-05-23 10:23:46 -04:00
|
|
|
overleaf:
|
2018-05-23 11:11:28 -04:00
|
|
|
id:
|
|
|
|
type: Number
|
|
|
|
index:
|
|
|
|
unique: true,
|
|
|
|
partialFilterExpression: {'overleaf.id': {$exists: true}}
|
2014-02-12 05:23:40 -05:00
|
|
|
|
|
|
|
|
|
|
|
SubscriptionSchema.statics.findAndModify = (query, update, callback)->
|
|
|
|
self = @
|
|
|
|
this.update query, update, ->
|
|
|
|
self.findOne query, callback
|
|
|
|
|
2018-11-16 04:02:57 -05:00
|
|
|
# Subscriptions have no v1 data to fetch
|
|
|
|
SubscriptionSchema.method 'fetchV1Data', (callback = (error, subscription)->) ->
|
|
|
|
callback(null, this)
|
|
|
|
|
2017-11-22 08:37:57 -05:00
|
|
|
conn = mongoose.createConnection(Settings.mongo.url, {
|
|
|
|
server: {poolSize: Settings.mongo.poolSize || 10},
|
|
|
|
config: {autoIndex: false}
|
|
|
|
})
|
2014-02-12 05:23:40 -05:00
|
|
|
|
|
|
|
Subscription = conn.model('Subscription', SubscriptionSchema)
|
|
|
|
|
|
|
|
mongoose.model 'Subscription', SubscriptionSchema
|
|
|
|
exports.Subscription = Subscription
|
2017-11-22 08:37:57 -05:00
|
|
|
exports.SubscriptionSchema = SubscriptionSchema
|