const mongoose = require('mongoose'); const mongoosePaginate = require('mongoose-paginate-v2'); function image(img) { if (img) return '/uploads/images/gallery/' + img } function graphic(img) { if (img) return '/uploads/graphics/gallery/' + img } function video(vdo) { if (vdo) return '/uploads/videos/gallery/' + vdo } const GallerySchema = mongoose.Schema({ title: String, shortTitlePanel: String, shortTitleFront: String, summaryTitle: String, shortSummaryTitle: String, leadTitle: String, catId: {type: mongoose.Schema.Types.ObjectId, ref: 'Category'}, rootParent: {type: mongoose.Schema.Types.ObjectId, ref: 'Category'}, allCat: [{type: mongoose.Schema.Types.ObjectId, ref: 'Category'}], newsFileId: {type: mongoose.Schema.Types.ObjectId, ref: 'NewsFile'}, // priority: {type : Number , default : 0}, publish: {type: Boolean, default: false}, showInHome: {type: Boolean, default: true}, graphic: {type: String, get: graphic, default: null}, thumbGraphic: {type: String, get: graphic, default: null}, cover: {type: String, get: image, default: null}, thumbCover: {type: String, get: image, default: null}, uidImage:[{type:String , get:image , default:null}], images: [{type: String, get: image, default: null}], thumbImages: [{type: String, get: image, default: null}], video: {type: String, get: video, default: null}, isEmbedded: {type: Boolean, default: false}, embeddedCode: String, userViews: {type: Number, default: 0}, special: {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}, modelType: String, keywords: {type: Array, default: []}, metaTagDesc: {type: String, default: null}, galleryType: {type: String, enum: ['image', 'video', 'graphic']}, galleryStatus: {type: Boolean, default: false}, customDate: {type: Date, default: Date.now}, customDateHistory: Array, favorite: {type: Boolean, default: false} }, {toJson: {getters: false}}); GallerySchema.plugin(mongoosePaginate); module.exports = mongoose.model('Gallery', GallerySchema);