21 lines
609 B
JavaScript
21 lines
609 B
JavaScript
const mongoose = require('mongoose');
|
|
const mongoosePaginate = require('mongoose-paginate-v2');
|
|
|
|
function image(img) {
|
|
if (img) return '/uploads/images/services/' + img
|
|
}
|
|
|
|
const ServicesSchema = mongoose.Schema({
|
|
title: String,
|
|
url : String,
|
|
cover : {type: String, get: image , default : null},
|
|
index: {type : Number , default : null},
|
|
_creator: {type: mongoose.Schema.Types.ObjectId , ref: 'User'},
|
|
_updatedBy: {type: mongoose.Schema.Types.ObjectId , ref: 'User'},
|
|
modelType : String
|
|
});
|
|
|
|
ServicesSchema.plugin(mongoosePaginate);
|
|
|
|
module.exports = mongoose.model('Services', ServicesSchema);
|