63 lines
1.5 KiB
JavaScript
Executable File
63 lines
1.5 KiB
JavaScript
Executable File
mongoose = require('mongoose').set('debug', false)
|
|
const Schema = mongoose.Schema;
|
|
|
|
const tools = require('../tools/general');
|
|
|
|
const shared_consts = require('../tools/shared_nodejs');
|
|
|
|
const { ObjectID } = require('mongodb');
|
|
|
|
mongoose.Promise = global.Promise;
|
|
mongoose.level = "F";
|
|
|
|
// A1P
|
|
|
|
// Resolving error Unknown modifier: $pushAll
|
|
mongoose.plugin(schema => {
|
|
schema.options.usePushEach = true
|
|
});
|
|
|
|
const ImportaMacroSchema = new Schema({
|
|
idapp: {
|
|
type: String,
|
|
},
|
|
_id: {
|
|
type: String,
|
|
},
|
|
|
|
});
|
|
|
|
var ImportaMacro = module.exports = mongoose.model('ImportaMacro', ImportaMacroSchema);
|
|
|
|
ImportaMacroSchema.index({ idapp: 1 });
|
|
|
|
module.exports.getFieldsForSearch = function () {
|
|
return [
|
|
{ field: 'name', type: tools.FieldType.string },
|
|
{ field: 'description', type: tools.FieldType.string },
|
|
]
|
|
};
|
|
|
|
module.exports.executeQueryTable = function (idapp, params) {
|
|
params.fieldsearch = this.getFieldsForSearch();
|
|
return tools.executeQueryTable(this, idapp, params);
|
|
};
|
|
|
|
module.exports.getImportaMacroByCode = function (idapp, code) {
|
|
return ImportaMacro.findAllIdApp(idapp, code);
|
|
}
|
|
|
|
module.exports.getImportaMacroById = async function (id) {
|
|
const arrris = await ImportaMacro.findAllIdApp('', '', id);
|
|
return arrris && arrris.length > 0 ? arrris[0] : null
|
|
}
|
|
|
|
module.exports.findAllIdApp = async function (idapp) {
|
|
const ImportaMacro = this;
|
|
|
|
const myfind = { idapp, deleted: false };
|
|
|
|
return await ImportaMacro.find(myfind, (err, arrrec) => {
|
|
return arrrec;
|
|
});
|
|
}; |