Files
modstagram-back/models/PartnerSearchAlertModel.js
payacom 3f416a7a60 full
2026-08-31 20:45:41 +03:30

36 lines
970 B
JavaScript

const mongoose = require('mongoose')
const timestamp = require('mongoose-timestamp')
/**
* A saved "find a partner" search — kept active indefinitely (per product
* decision) so the searcher keeps getting notified on every new matching
* user, not just once. `notified_user_ids` dedupes so the same matched user
* doesn't trigger a repeat notification for the same alert.
*/
const partnerSearchAlertSchema = new mongoose.Schema({
user_id: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
required: true,
index: true
},
criteria: {
type: mongoose.Schema.Types.Mixed,
required: true
},
notified_user_ids: {
type: [mongoose.Schema.Types.ObjectId],
default: []
},
active: {
type: Boolean,
default: true,
index: true
}
})
partnerSearchAlertSchema.plugin(timestamp)
const PartnerSearchAlertModel = mongoose.model('PartnerSearchAlert', partnerSearchAlertSchema)
module.exports = PartnerSearchAlertModel