62 lines
2.0 KiB
JavaScript
62 lines
2.0 KiB
JavaScript
const mongoose = require('mongoose');
|
|
const mongoosePaginate = require('mongoose-paginate-v2');
|
|
|
|
function image(img) {
|
|
if (img) return '/uploads/images/news/' + img
|
|
else return '/img/no-cover.jpg'
|
|
}
|
|
|
|
function file(file) {
|
|
return '/uploads/files/newsAttachments/' + file
|
|
}
|
|
|
|
const NewsAttachmentSchema = mongoose.Schema({
|
|
file: {type: String, get: file},
|
|
title: String
|
|
})
|
|
|
|
const NewsSchema = mongoose.Schema({
|
|
title: String,
|
|
shortTitlePanel: String,
|
|
shortTitleFront: String,
|
|
summaryTitle: String,
|
|
leadTitle: String,
|
|
shortSummaryTitle: String,
|
|
customDate: {type: Date, default: Date.now},
|
|
catId: {type: mongoose.Schema.Types.ObjectId, ref: 'Category'},
|
|
allCat: [{type: mongoose.Schema.Types.ObjectId, ref: 'Category'}],
|
|
newsFileId: {type: mongoose.Schema.Types.ObjectId, ref: 'NewsFile'},
|
|
rootParent: {type: mongoose.Schema.Types.ObjectId, ref: 'Category'},
|
|
priority: {type: Boolean, default: false},
|
|
allowComment: {type: Boolean, default: false},
|
|
showInHome: {type: Boolean, default: true},
|
|
slider: {type: Boolean, default: false},
|
|
PublisherId:{type:String},
|
|
PublisherAccept:{type:Boolean , default:false},
|
|
publish: {type: Boolean, default: false},
|
|
pageContent: String,
|
|
cover: {type: String, get: image, default: null},
|
|
thumbCover: {type: String, get: image, default: null},
|
|
content:{type:String , default:''},
|
|
userViews: {type: Number, default: 0},
|
|
special: {type: Boolean, default: false},
|
|
notifications: {type: Boolean, default: false},
|
|
_creator: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
|
|
_updatedBy: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
|
|
siteMap: {type: Boolean, default: true},
|
|
keywords: {type: Array, default: []},
|
|
metaTagDesc: {type: String, default: null},
|
|
newsStatus: {type: Boolean, default: false},
|
|
modelType: String,
|
|
customDateHistory: Array,
|
|
attachments: [NewsAttachmentSchema],
|
|
imported: Boolean,
|
|
superNews: Boolean
|
|
});
|
|
|
|
NewsSchema.index({catId: 1, allCat: 1});
|
|
|
|
NewsSchema.plugin(mongoosePaginate);
|
|
|
|
module.exports = mongoose.model('News', NewsSchema);
|