23 lines
719 B
JavaScript
23 lines
719 B
JavaScript
const mongoose = require('mongoose');
|
|
const mongoosePaginate = require('mongoose-paginate-v2');
|
|
|
|
function image(img) {
|
|
if (img) return '/uploads/images/occasion/' + img
|
|
}
|
|
|
|
const OccasionSchema = mongoose.Schema({
|
|
title : String,
|
|
mainCover: {type: String, get: image, default: null},
|
|
startDate : Date,
|
|
endDate : Date,
|
|
index: {type: Number, default: null},
|
|
publish : {type : Boolean , default: true},
|
|
status : {type : Boolean , default: false},
|
|
_creator :{type: mongoose.Schema.Types.ObjectId, ref: 'User'},
|
|
_updatedBy: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
|
|
});
|
|
|
|
OccasionSchema.plugin(mongoosePaginate);
|
|
|
|
module.exports = mongoose.model('Occasion', OccasionSchema);
|