module.exports = function(mongoose) { var Schema = mongoose.Schema; var mongoosePages = require('mongoose-pages'); // create a schema var lessonsSchema = new Schema({ //Define schema object title: String, created_at: String, }, {collection: 'lessons'}); mongoosePages.skip(lessonsSchema); // makes the findPaginated() method available return mongoose.model('lessons', lessonsSchema); }
ref: 'User' } ], updated: { type: Date }, created: { type: Date, default: Date.now } }); /** * Activate pagination plugin. */ mongoosePages.skip(ProjectSchema); /** * Finds all Projects and return them in a paginated way. * * @param page the page to return. * @returns {*} a promise. */ ProjectSchema.statics.findAllPaginated = function (page) { var me = this; return new Q(function (resolve, reject) { me.findPaginated({}, null, {sort: {'project_id': 'ascending'}}, function (err, result) { if (err) { reject(err); }
type: Schema.ObjectId, ref: 'Project' }, updated: { type: Date }, created: { type: Date, default: Date.now } }); /** * Activate pagination plugin. */ mongoosePages.skip(BookingSchema); /** * Validate that start date must be greater than end date. */ BookingSchema.path('start').validate(function (value, done) { done(this.start < this.end); }, 'End date must be greater than start date.'); /** * Validate that no overlapping bookings are allowed. */ BookingSchema.path('end').validate(function (value, done) { if (!this.isModified('start') && !this.isModified('end')) { return done(true); }