Files
ostandari/server/models/Content.js
T
2026-06-19 15:47:02 +03:30

30 lines
1.0 KiB
JavaScript

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/content/${img}`);
}
const ContentSchema = mongoose.Schema({
title: String,
param: String,
email: String,
cover: {type: String, get: image, default: null},
thumb: {type: String, get: image, default: null},
showInMenu: {type: Boolean, default: false},
pageContent: String,
showInFooter: {type: Number, enum: [0, 1, 2, 3], default: 0},
showInSubFooter: {type: Boolean, default: false},
index: {type: Number, default: null},
private: {type: Boolean, default: true},
_creator: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
_updatedBy: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
siteMap: {type: Boolean, default: true},
modelType: {type: String, default: 'ostandari'}
});
module.exports = mongoose.model('Content', ContentSchema);