Files
freeplanet_serverside/src/server/models/skill.js
Paolo Arena 3d7471f2d2 Sorting fixed
- added tables Skills, Sectors,
2021-10-05 00:20:12 +02:00

60 lines
1.1 KiB
JavaScript
Executable File

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 SkillSchema = new Schema({
descr: {
type: String,
},
idSector: {
type: String
},
icon: {
type: String,
},
img: {
type: String,
},
});
SkillSchema.statics.findAllIdApp = function (idapp) {
const Skill = this;
const query = [
{ $sort: { descr: 1 } }
];
return Skill
.aggregate(query)
.then((arrrec) => {
return arrrec
})
};
SkillSchema.statics.getFieldsForSearch = function () {
return [{ field: 'label', type: tools.FieldType.string },
{ field: 'descr', type: tools.FieldType.string }]
};
SkillSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, 0, params);
};
const Skill = mongoose.model('Skill', SkillSchema);
module.exports = { Skill };