const mongoose = require('mongoose') const paginate = require('mongoose-paginate-v2') function video(vid) { if (vid) return '/uploads/videos/' + vid } function image(img) { return '/uploads/images/blog/' + img } function thumb(img) { return '/uploads/images/blog/thumb/' + img } const LearningSchema = mongoose.Schema({ _creator: { type: mongoose.ObjectId, ref: 'User' }, title: String, short_description: String, description: String, cover: { type: String, get: image }, video: { type: String, get: video }, thumb: { type: String, get: thumb } }) LearningSchema.plugin(paginate) module.exports = mongoose.model('Learning', LearningSchema)