const mongoose = require('mongoose'); const s3Storage = require('../plugins/s3Storage'); function image(img) { if (!img) return null; if (img.startsWith('http://') || img.startsWith('https://')) return img; return s3Storage.getPublicUrl(`uploads/images/mainCover/${img}`); } const YearBannerSchema = mongoose.Schema({ mainCover: {type: String, get: image, default: null}, iranFlag: {type: Boolean, default: true}, // electionBtn electionBtn: {type: Boolean, default: true}, // social links hasEmail: {type: Boolean, default: true}, hasGPlus: {type: Boolean, default: true}, hasTweeter: {type: Boolean, default: true}, hasInstagram: {type: Boolean, default: true}, email: {type: String, default: ''}, gPlus: {type: String, default: ''}, tweeter: {type: String, default: ''}, instagram: {type: String, default: ''}, // textCover : {type : String , default : null}, _updatedBy: {type: mongoose.Schema.Types.ObjectId, ref: 'User'}, }); module.exports = mongoose.model('YearBanner', YearBannerSchema);