2019-12-07 00:20:06 +01:00
|
|
|
const mongoose = require('mongoose');
|
|
|
|
|
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 MyPageSchema = new Schema({
|
|
|
|
|
idapp: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
author_username: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2019-12-31 00:44:53 +01:00
|
|
|
lang: {
|
2019-12-07 00:20:06 +01:00
|
|
|
type: String,
|
|
|
|
|
},
|
2019-12-31 00:44:53 +01:00
|
|
|
title: {
|
2019-12-07 00:20:06 +01:00
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
icon: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2019-12-31 00:44:53 +01:00
|
|
|
order: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 1000,
|
|
|
|
|
},
|
|
|
|
|
path: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2019-12-07 00:20:06 +01:00
|
|
|
keywords: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
description: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
heightimg: {
|
|
|
|
|
type: Number,
|
|
|
|
|
},
|
2020-01-20 01:48:25 +01:00
|
|
|
onlyif_logged: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
2019-12-07 00:20:06 +01:00
|
|
|
imgback: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
content: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
active: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
|
|
|
|
inmenu: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
|
|
|
|
submenu: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
|
|
|
|
l_par: {
|
|
|
|
|
type: Number,
|
|
|
|
|
},
|
|
|
|
|
l_child: {
|
|
|
|
|
type: Number,
|
|
|
|
|
},
|
|
|
|
|
infooter: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
MyPageSchema.statics.getFieldsForSearch = function () {
|
2020-03-21 10:28:26 +01:00
|
|
|
return [{ field: 'title', type: tools.FieldType.string },
|
|
|
|
|
{ field: 'keywords', type: tools.FieldType.string },
|
|
|
|
|
{ field: 'description', type: tools.FieldType.string },
|
|
|
|
|
{ field: 'content', type: tools.FieldType.string }]
|
2019-12-07 00:20:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MyPageSchema.statics.executeQueryTable = function (idapp, params) {
|
|
|
|
|
params.fieldsearch = this.getFieldsForSearch();
|
|
|
|
|
return tools.executeQueryTable(this, idapp, params);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MyPageSchema.statics.findAllIdApp = async function (idapp) {
|
|
|
|
|
const MyPage = this;
|
|
|
|
|
|
|
|
|
|
const myfind = { idapp };
|
|
|
|
|
|
|
|
|
|
return await MyPage.find(myfind, (err, arrrec) => {
|
|
|
|
|
return arrrec
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const MyPage = mongoose.model('MyPage', MyPageSchema);
|
|
|
|
|
|
|
|
|
|
module.exports = { MyPage };
|