Files
modstagram-back/models/ShareableLinkModel.js
2026-09-24 21:03:27 +03:30

29 lines
1.1 KiB
JavaScript

const mongoose = require('mongoose')
const timestamp = require('mongoose-timestamp')
// اشتراک‌گذاری لینک: کاربر مشخص می‌کنه کدوم محتوای خودش (پکیج/پروژه/بیلبورد/فروشگاه/
// کالا/رزرو) وقتی یکی دیگه توی ثبت پست تگش می‌کنه، توی لیست لینک‌های قابل‌انتخاب اون
// کاربر (بلاگر) نشون داده بشه — shareableLinksController.js/for-users همین رکوردها رو می‌خونه
const shareableLinkSchema = new mongoose.Schema({
user_id: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
required: true
},
kind: {
type: String,
enum: ['pkg', 'project', 'billboard', 'shop', 'shopproduct', 'booking'],
required: true
},
ref_id: {
type: String,
required: true
}
})
shareableLinkSchema.index({ user_id: 1, kind: 1, ref_id: 1 }, { unique: true })
shareableLinkSchema.plugin(timestamp)
const ShareableLinkModel = mongoose.model('ShareableLink', shareableLinkSchema)
module.exports = ShareableLinkModel