19 lines
513 B
JavaScript
19 lines
513 B
JavaScript
const mongoose = require('mongoose')
|
|
|
|
function image(img) {
|
|
if (img) return '/uploads/images/announcement/' + img
|
|
}
|
|
|
|
const AnnouncementSchema = mongoose.Schema({
|
|
title: String,
|
|
caption: String,
|
|
seenBy: [mongoose.ObjectId],
|
|
expireDate: Number,
|
|
expired: { type: Boolean, default: false },
|
|
isForAgents: { type: Boolean, default: false },
|
|
image: { type: String, get: image },
|
|
_creator: { type: mongoose.ObjectId, ref: 'User' }
|
|
})
|
|
|
|
module.exports = mongoose.model('Announcement', AnnouncementSchema)
|