88 lines
1.5 KiB
JavaScript
88 lines
1.5 KiB
JavaScript
|
|
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,
|
||
|
|
},
|
||
|
|
title: {
|
||
|
|
type: String,
|
||
|
|
},
|
||
|
|
path: {
|
||
|
|
type: String,
|
||
|
|
},
|
||
|
|
icon: {
|
||
|
|
type: String,
|
||
|
|
},
|
||
|
|
keywords: {
|
||
|
|
type: String,
|
||
|
|
},
|
||
|
|
description: {
|
||
|
|
type: String,
|
||
|
|
},
|
||
|
|
heightimg: {
|
||
|
|
type: Number,
|
||
|
|
},
|
||
|
|
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 () {
|
||
|
|
return ['title', 'keywords', 'description', 'content']
|
||
|
|
};
|
||
|
|
|
||
|
|
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 };
|