full
This commit is contained in:
35
models/PartnerSearchAlertModel.js
Normal file
35
models/PartnerSearchAlertModel.js
Normal file
@@ -0,0 +1,35 @@
|
||||
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
|
||||
Reference in New Issue
Block a user