24 lines
762 B
JavaScript
24 lines
762 B
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/links/${img}`);
|
|
}
|
|
|
|
const LinksSchema = mongoose.Schema({
|
|
title: String,
|
|
url : String,
|
|
icon : {type: String, get: image , default : null},
|
|
index: {type : Number , default : null},
|
|
showInHome : {type : Boolean , default : false},
|
|
_creator: {type: mongoose.Schema.Types.ObjectId , ref: 'User'},
|
|
_updatedBy: {type: mongoose.Schema.Types.ObjectId , ref: 'User'},
|
|
siteMap : {type : Boolean , default : false},
|
|
modelType : String
|
|
});
|
|
|
|
|
|
module.exports = mongoose.model('Links', LinksSchema);
|