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

@@ -29,31 +29,106 @@ const modelSchema = new mongoose.Schema({
type: String,
required: false,
trim: true,
minLength: 1,
maxLength: 1000,
maxLength: 2000,
default: null,
},
status: {
type: String,
required: false,
trim: true,
enum: ['pending', 'accept', 'reject'],
enum: ['pending', 'temp_accept', 'accept', 'reject'],
default: 'pending',
},
report_hidden: {
type: Boolean,
default: false,
},
is_archived: {
type: Boolean,
default: false,
},
archived_at: {
type: Date,
default: null,
},
user_id: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
},
tagged_users: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
}],
linked_course_id: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Course',
default: null,
},
linked_project_id: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Project',
default: null,
},
linked_billboard_id: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Advertising',
default: null,
},
linked_shop_id: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Shop',
default: null,
},
linked_shop_product_id: {
type: mongoose.Schema.Types.ObjectId,
ref: 'ShopProductListing',
default: null,
},
// برخلاف بقیه‌ی linked_*_id ها که _id خودِ آیتم لینک‌شده رو نگه می‌دارن، این یکی userId
// مالک کانفیگ رزروئه (نه _id خودِ BookingConfig) — چون صفحه‌ی عمومی رزرو با userId
// مسیردهی می‌شه (/booking/[userId]) نه شناسه‌ی کانفیگ
linked_booking_id: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
default: null,
},
likes: [{
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
}],
lat: {
type: String,
trim: true,
default: null,
},
lng: {
type: String,
trim: true,
default: null,
},
country: {
type: Object,
default: null,
},
province: {
type: Object,
default: null,
},
city: {
type: Object,
default: null,
},
comments: {
type: Object,
default: null,
},
});
// getUserPosts/getUserPostsWeb (postController.js) هر بار پروفایل باز می‌شه دقیقاً
// همین سه فیلد رو فیلتر و createdAt رو سورت می‌کنن — بدونِ ایندکس یه scan کامل +
// sort توی حافظه‌ست
modelSchema.index({ user_id: 1, status: 1, is_archived: 1, createdAt: -1 });
modelSchema.plugin(timestamp);
modelSchema.plugin(mongoosePaginate);
const PostModel = mongoose.model('Post', modelSchema);