Files
freeplanet_serverside/src/server/models/myelem.js

122 lines
1.9 KiB
JavaScript
Raw Normal View History

2022-10-27 11:22:58 +02:00
const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
const tools = require('../tools/general');
mongoose.Promise = global.Promise;
mongoose.level = "F";
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const MyElemSchema = new Schema({
idapp: {
type: String,
},
type: {
2022-10-29 12:37:50 +02:00
type: Number,
2022-10-27 11:22:58 +02:00
},
title: {
type: String,
},
container: {
type: String,
},
2022-10-29 12:37:50 +02:00
container2: {
type: String,
},
container3: {
type: String,
},
number: {
type: String,
},
imgback: {
type: String,
},
ratio: {
type: String,
},
containerHtml: {
type: String,
},
2022-10-27 11:22:58 +02:00
size: {
type: String,
},
order: {
type: Number,
default: 0,
},
height: {
type: Number,
},
2022-10-29 12:37:50 +02:00
heightimg: {
type: Number,
},
widthimg: {
type: Number,
},
width: {
type: Number,
},
link: {
type: String,
},
2022-10-27 11:22:58 +02:00
onlyif_logged: {
type: Boolean,
},
color: {
type: String,
},
active: {
type: Boolean,
},
class: {
type: String,
},
2022-10-29 12:37:50 +02:00
styleadd: {
type: String,
},
list: [
{
imagefile: {
type: String
},
order: {
type: Number
},
alt: {
type: String
},
description: {
type: String
}
}
],
2022-10-27 11:22:58 +02:00
});
MyElemSchema.statics.getFieldsForSearch = function () {
return [{ field: 'title', type: tools.FieldType.string },
{ field: 'content', type: tools.FieldType.string }]
};
MyElemSchema.statics.executeQueryTable = function (idapp, params, user) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params, user);
};
MyElemSchema.statics.findAllIdApp = async function (idapp) {
const MyElem = this;
const myfind = { idapp };
2022-10-29 12:37:50 +02:00
return await MyElem.find(myfind).sort({ order: 1 });
2022-10-27 11:22:58 +02:00
};
const MyElem = mongoose.model('MyElem', MyElemSchema);
module.exports = { MyElem };