This commit is contained in:
payacom
2026-08-31 20:45:41 +03:30
parent fa9f23c61d
commit 3f416a7a60
367 changed files with 621895 additions and 6443 deletions

View File

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