Files
ostandari/server/models/Comment.js
T
2024-10-21 10:22:26 +03:30

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);