full
This commit is contained in:
@@ -37,18 +37,34 @@ const commentSchema = new mongoose.Schema({
|
||||
ref: 'Post',
|
||||
required: false
|
||||
},
|
||||
shop_product: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'ShopProductListing',
|
||||
required: false
|
||||
},
|
||||
parent: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'Comment',
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
comment_for: {
|
||||
type: String,
|
||||
enum: ['user', 'project', 'post'],
|
||||
enum: ['user', 'project', 'post', 'shop_product'],
|
||||
required: true
|
||||
},
|
||||
status: {
|
||||
type: String,
|
||||
enum: ['pending', 'accepted', 'rejected'],
|
||||
enum: ['pending', 'temp_accept', 'accepted', 'rejected'],
|
||||
default: 'pending'
|
||||
}
|
||||
})
|
||||
|
||||
// postController.js هر بار جزئیاتِ پست باز میشه CommentModel.countDocuments({post,status})
|
||||
// میزنه؛ getUserController.js هم لیستِ کامنتهای یه کاربر رو با user فیلتر میکنه
|
||||
commentSchema.index({ post: 1, status: 1 })
|
||||
commentSchema.index({ user: 1 })
|
||||
|
||||
commentSchema.plugin(timestamp)
|
||||
commentSchema.plugin(mongoosePaginate)
|
||||
const CommentModel = mongoose.model('Comment', commentSchema)
|
||||
|
||||
Reference in New Issue
Block a user