60 lines
1.1 KiB
JavaScript
Executable File
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 };
|