Snaplocal / server /src /models /Notification.js
Kuruva Laxmi
SnapLocal MVP - Complete platform with 4 MVP features
0f8617c
Raw
History Blame Contribute Delete
738 Bytes
const mongoose = require('mongoose');
const notificationSchema = new mongoose.Schema({
recipient: {
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
required: true
},
type: {
type: String,
enum: ['booking', 'message', 'review', 'system'],
required: true
},
content: {
type: String,
required: true
},
link: {
type: String
},
isRead: {
type: Boolean,
default: false
}
}, { timestamps: true });
// Index for fetching unread notifications for a user
notificationSchema.index({ recipient: 1, isRead: 1 });
const Notification = mongoose.model('Notification', notificationSchema);
module.exports = Notification;