47 lines
937 B
JavaScript
47 lines
937 B
JavaScript
|
|
const mongoose = require('mongoose');
|
||
|
|
const Schema = mongoose.Schema;
|
||
|
|
|
||
|
|
const tools = require('../tools/general');
|
||
|
|
|
||
|
|
mongoose.Promise = global.Promise;
|
||
|
|
mongoose.level = "F";
|
||
|
|
|
||
|
|
|
||
|
|
// Resolving error Unknown modifier: $pushAll
|
||
|
|
mongoose.plugin(schema => {
|
||
|
|
schema.options.usePushEach = true
|
||
|
|
});
|
||
|
|
|
||
|
|
const OpzEmailSchema = new Schema({
|
||
|
|
key: {
|
||
|
|
type: String,
|
||
|
|
default: ''
|
||
|
|
},
|
||
|
|
label_it: {
|
||
|
|
type: String,
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
|
||
|
|
OpzEmailSchema.statics.getFieldsForSearch = function () {
|
||
|
|
return ['label_it']
|
||
|
|
};
|
||
|
|
|
||
|
|
OpzEmailSchema.statics.executeQueryTable = function (idapp, params) {
|
||
|
|
params.fieldsearch = this.getFieldsForSearch();
|
||
|
|
return tools.executeQueryTable(this, 0, params);
|
||
|
|
};
|
||
|
|
|
||
|
|
OpzEmailSchema.statics.findAllIdApp = async function (idapp) {
|
||
|
|
const OpzEmail = this;
|
||
|
|
|
||
|
|
return await OpzEmail.find({}, (err, arrrec) => {
|
||
|
|
return arrrec
|
||
|
|
});
|
||
|
|
};
|
||
|
|
|
||
|
|
|
||
|
|
const OpzEmail = mongoose.model('OpzEmail', OpzEmailSchema);
|
||
|
|
|
||
|
|
module.exports = { OpzEmail };
|