overleaf/services/web/app/coffee/models/Subscription.coffee

40 lines
1.2 KiB
CoffeeScript
Raw Normal View History

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}}
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
planCode : {type: String}
groupPlan : {type: Boolean, default: false}
membersLimit: {type:Number, default:0}
customAccount: Boolean
2014-02-12 05:23:40 -05:00
freeTrial:
expiresAt: Date
downgraded: Boolean
planCode: String
allowed: {type: Boolean, default: true}
SubscriptionSchema.statics.findAndModify = (query, update, callback)->
self = @
this.update query, update, ->
self.findOne query, callback
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
exports.SubscriptionSchema = SubscriptionSchema