diff options
author | Dennis Eriksen <dennis.se@gmail.com> | 2013-04-30 14:41:30 +0200 |
---|---|---|
committer | Dennis Eriksen <dennis.se@gmail.com> | 2013-04-30 14:41:30 +0200 |
commit | d556ef525f593ccb8c688e340f70659849ac74a3 (patch) | |
tree | 48343fe585cbf1741be0ef587d0fe792a7bb0690 /models/Access.js | |
parent | made a page for adding participants to projects (diff) | |
download | Divid-d556ef525f593ccb8c688e340f70659849ac74a3.tar.gz |
renamed files to match model names
Diffstat (limited to 'models/Access.js')
-rw-r--r-- | models/Access.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/models/Access.js b/models/Access.js new file mode 100644 index 0000000..ce75f8c --- /dev/null +++ b/models/Access.js @@ -0,0 +1,42 @@ + +/** + * Module dependencies + */ + +var mongoose = require('mongoose') + , Schema = mongoose.Schema; + +var AccessSchema = new Schema({ + user: { type: Schema.ObjectId, ref: 'User' }, + creator: { type: Schema.ObjectId, ref: 'User' }, + project: { type: Schema.ObjectId, ref: 'Project' }, + permissions: { type: Number, default: '3' }, + created: { type: Date, default: Date.now }, + updated: { type: Date, default: Date.now } +}); + +// the four validations below only apply if you are signing up traditionally + +AccessSchema.statics = { + + log: function() { + console.log('wat. wat logged this'); + }, + + /** + * Load ALL accesses for a single user + * + * @param {ObjectId} id + * @param {Function} callback + * @api private + */ + + loadUser: function(id, callback) { + this.find({ user: id }) + .populate('project') + .sort({ 'created': -1 }) // sort by date + .exec(callback); + } +} + +mongoose.model('Access', AccessSchema); |