2025-11-03 20:35:01 +00:00
|
|
|
const mongoose = require('mongoose');
|
|
|
|
|
|
|
|
|
|
const NotificationSchema = new mongoose.Schema({
|
|
|
|
|
recipient: {
|
|
|
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
|
|
|
ref: 'User',
|
|
|
|
|
required: true
|
|
|
|
|
},
|
|
|
|
|
sender: {
|
|
|
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
|
|
|
ref: 'User',
|
|
|
|
|
required: true
|
|
|
|
|
},
|
|
|
|
|
type: {
|
|
|
|
|
type: String,
|
2025-12-04 20:00:39 +00:00
|
|
|
enum: ['follow', 'like', 'comment', 'mention', 'new_post'],
|
2025-11-03 20:35:01 +00:00
|
|
|
required: true
|
|
|
|
|
},
|
|
|
|
|
post: {
|
|
|
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
|
|
|
ref: 'Post'
|
|
|
|
|
},
|
|
|
|
|
read: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false
|
|
|
|
|
},
|
|
|
|
|
createdAt: {
|
|
|
|
|
type: Date,
|
|
|
|
|
default: Date.now
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
module.exports = mongoose.model('Notification', NotificationSchema);
|
|
|
|
|
|