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

30 lines
856 B
CoffeeScript
Raw Normal View History

mongoose = require 'mongoose'
Settings = require 'settings-sharelatex'
Schema = mongoose.Schema
ObjectId = Schema.ObjectId
2016-07-21 09:20:09 -04:00
THIRTY_DAYS_IN_SECONDS = 60 * 60 * 24 * 30
makeExpirationDate = () ->
nowInMillis = Date.now()
new Date(nowInMillis + (1000 * THIRTY_DAYS_IN_SECONDS))
ProjectInviteSchema = new Schema
email: String
2016-07-21 09:20:09 -04:00
token: String
sendingUserId: ObjectId
projectId: ObjectId
privileges: String
createdAt: {type: Date, default: Date.now}
expiresAt: {type: Date, default: makeExpirationDate}
conn = mongoose.createConnection(Settings.mongo.url, server: poolSize: Settings.mongo.poolSize || 10)
ProjectInvite = conn.model('ProjectInvite', ProjectInviteSchema)
mongoose.model 'ProjectInvite', ProjectInviteSchema
exports.ProjectInvite = ProjectInvite
2016-07-21 09:20:09 -04:00
exports.ProjectInviteSchema = ProjectInviteSchema