Sorting fixed

- added tables Skills, Sectors,
This commit is contained in:
Paolo Arena
2021-10-05 00:20:12 +02:00
parent 177489521d
commit 3d7471f2d2
8 changed files with 286 additions and 14 deletions

59
src/server/models/skill.js Executable file
View File

@@ -0,0 +1,59 @@
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 };