2022-09-14 11:32:04 +02:00
|
|
|
const mongoose = require('mongoose').set('debug', false)
|
2019-12-04 02:03:44 +01:00
|
|
|
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 TemplEmailSchema = new Schema({
|
|
|
|
|
idapp: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
subject: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
testoheadermail: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
content: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
img: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
content2: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
img2: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
options: [{
|
|
|
|
|
type: String,
|
|
|
|
|
}]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
TemplEmailSchema.statics.getFieldsForSearch = function () {
|
2020-03-21 10:28:26 +01:00
|
|
|
return []
|
2019-12-04 02:03:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TemplEmailSchema.statics.executeQueryTable = function (idapp, params) {
|
|
|
|
|
params.fieldsearch = this.getFieldsForSearch();
|
|
|
|
|
return tools.executeQueryTable(this, idapp, params);
|
|
|
|
|
};
|
|
|
|
|
|
2020-01-13 23:52:51 +01:00
|
|
|
TemplEmailSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
|
|
|
|
|
2022-09-11 11:45:33 +02:00
|
|
|
return await tools.DuplicateAllRecords(this, idapporig, idappdest);
|
2020-01-13 23:52:51 +01:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2019-12-04 02:03:44 +01:00
|
|
|
|
|
|
|
|
TemplEmailSchema.statics.findAllIdApp = async function (idapp) {
|
|
|
|
|
const TemplEmail = this;
|
|
|
|
|
|
|
|
|
|
const myfind = { idapp };
|
|
|
|
|
|
2022-09-11 11:45:33 +02:00
|
|
|
return await TemplEmail.find(myfind).lean();
|
2019-12-04 02:03:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const TemplEmail = mongoose.model('TemplEmail', TemplEmailSchema);
|
|
|
|
|
|
2023-12-09 11:55:58 +01:00
|
|
|
TemplEmail.createIndexes((err) => {
|
|
|
|
|
if (err) throw err;
|
|
|
|
|
});
|
|
|
|
|
|
2019-12-04 02:03:44 +01:00
|
|
|
module.exports = { TemplEmail };
|