33 lines
821 B
JavaScript
33 lines
821 B
JavaScript
const mongoose = require('mongoose');
|
|
const mongoosePaginate = require('mongoose-paginate-v2');
|
|
|
|
|
|
const CommentSchema = mongoose.Schema({
|
|
name : String,
|
|
description: String,
|
|
email : String,
|
|
read : {type : Boolean , default : false},
|
|
allowShow : {type : Boolean , default : false},
|
|
catsId : {type : Array , default : []},
|
|
_updatedBy: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
ref: 'User'
|
|
},
|
|
modelRef : {
|
|
type : mongoose.Schema.Types.ObjectId,
|
|
refPath: 'modelName'
|
|
},
|
|
modelName : {
|
|
type: String,
|
|
required: true,
|
|
enum: ['News', 'Category' , 'ContactUs']
|
|
},
|
|
modelType : String
|
|
});
|
|
|
|
CommentSchema.index({modelRef: 1});
|
|
|
|
CommentSchema.plugin(mongoosePaginate);
|
|
|
|
module.exports = mongoose.model('Comment', CommentSchema);
|