Files
gameno-api/components/notifications/notificationModel.js
T
kavehhn f04c797be6 Initial commit: teaching institution management API.
Express/MongoDB backend with JWT auth, RBAC, S3 uploads, notifications, and scheduled jobs.
2026-08-09 04:18:08 +02:00

58 lines
966 B
JavaScript

// /components/notifications/notificationModel.js
const mongoose = require('mongoose');
const notificationSchema = new mongoose.Schema({
user: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
index: true
},
channel: {
type: String,
enum: ['email', 'sms', 'baleBot'],
required: true
},
subject: {
type: String,
trim: true
},
body: {
type: String,
required: true,
trim: true
},
status: {
type: String,
enum: ['pending', 'sent', 'delivered', 'failed', 'retrying'],
default: 'pending',
index: true
},
retryCount: {
type: Number,
default: 0
},
maxRetries: {
type: Number,
default: 3
},
lastError: {
type: String,
trim: true
},
sentAt: {
type: Date
},
deliveredAt: {
type: Date
},
relatedEvent: {
type: String,
trim: true
}
}, {
timestamps: true
});
module.exports = mongoose.model('Notification', notificationSchema);