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

@@ -18,6 +18,12 @@ const likeSchema = new mongoose.Schema({
}]
})
// postController.js هر بار جزئیاتِ یه پست رو می‌گیره LikeModel.findOne({userId, postId})
// می‌زنه — بدونِ ایندکس این یه scan کاملِ کالکشنه. عمداً unique نیست — دیتای فعلیِ
// production حداقل یه گروهِ تکراریِ {postId,userId} داره؛ ساختِ ایندکسِ unique روی
// این دیتا شکست می‌خوره. بعد از پاک‌سازیِ دستیِ تکراری‌ها می‌شه unique هم اضافه کرد
likeSchema.index({ postId: 1, userId: 1 })
// تعریف مدل LikeModel
likeSchema.plugin(timestamp)
const LikeModel = mongoose.model('Like', likeSchema)