7fife-backend/models/notification.model.js

36 lines
962 B
JavaScript
Raw Permalink Normal View History

2024-03-07 13:01:44 +00:00
const mongoose = require('mongoose');
const constant = require('../util/notification.constant')
const Schema = mongoose.Schema;
2024-03-07 13:01:44 +00:00
const notificationSchema = new mongoose.Schema({
userId: { type: Schema.Types.ObjectId, ref: 'User' },
2024-03-07 13:01:44 +00:00
sendTo: {
type: [String],
enum: [constant.sendTo.toAll, constant.sendTo.host, constant.sendTo.specific],
required: true
},
Type: {
type: [String],
enum: [constant.notificationType.email, constant.notificationType.sms, constant.notificationType.push],
required: true
},
user: {
type: [String],
default: []
},
Title: {
type: String,
required: true
},
message: {
type: String,
required: true
},
// recipients: {
// type: [mongoose.SchemaType.objectId],
// default: []
// }
2024-03-07 13:01:44 +00:00
}, { timestamps: true });
module.exports = mongoose.model('Notification', notificationSchema);