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

56 lines
1.1 KiB
JavaScript
Raw Normal View History

const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
const tools = require('../tools/general');
const { ObjectID } = require('mongodb');
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const SectorSchema = new Schema({
descr: {
type: String,
},
icon: {
type: String,
},
img: {
type: String,
},
});
SectorSchema.statics.findAllIdApp = function (idapp) {
const Sector = this;
const query = [
{ $sort: { descr: 1 } }
];
return Sector
.aggregate(query)
.then((arrrec) => {
return arrrec
})
};
SectorSchema.statics.getFieldsForSearch = function () {
return [{ field: 'descr', type: tools.FieldType.string }]
};
SectorSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, 0, params);
};
const Sector = mongoose.model('Sector', SectorSchema);
module.exports = { Sector };