Corretto Duplicazione Sito (es: da 1 a 14)
This commit is contained in:
@@ -60,6 +60,13 @@ BotSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
BotSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
||||
|
||||
return tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
|
||||
};
|
||||
|
||||
|
||||
BotSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const Bot = this;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ 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
|
||||
@@ -11,7 +12,7 @@ mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const cfgserverSchema = new Schema({
|
||||
const CfgServerSchema = new Schema({
|
||||
chiave: {
|
||||
type: String,
|
||||
trim: true,
|
||||
@@ -28,4 +29,19 @@ const cfgserverSchema = new Schema({
|
||||
},
|
||||
});
|
||||
|
||||
mongoose.model('cfgserver', cfgserverSchema);
|
||||
CfgServerSchema.statics.DuplicateAllRecords = async function (idapporig, idappdest) {
|
||||
|
||||
return tools.DuplicateAllRecords(this, idapporig, idappdest);
|
||||
|
||||
};
|
||||
|
||||
CfgServerSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const myfind = { idapp };
|
||||
|
||||
return await CfgServer.find(myfind).lean();
|
||||
};
|
||||
|
||||
const CfgServer = mongoose.model('CfgServer', CfgServerSchema);
|
||||
|
||||
module.exports = {CfgServer};
|
||||
|
||||
|
||||
@@ -91,32 +91,36 @@ SettingsSchema.statics.DuplicateAllRecords = async function (idapporig, idappdes
|
||||
SettingsSchema.statics.findAllIdApp = async function (idapp, serv, crypted = false) {
|
||||
const Settings = this;
|
||||
|
||||
let myfind = '';
|
||||
if (serv) {
|
||||
myfind = {idapp, serv };
|
||||
} else
|
||||
myfind = { idapp };
|
||||
try {
|
||||
let myfind = '';
|
||||
if (serv) {
|
||||
myfind = {idapp, serv};
|
||||
} else
|
||||
myfind = {idapp};
|
||||
|
||||
// myfind = {...myfind, $or: [{ crypted: { $exists: false } }, { crypted: { $exists: true, $eq: crypted } }]};
|
||||
// myfind = {...myfind, $or: [{ crypted: { $exists: false } }, { crypted: { $exists: true, $eq: crypted } }]};
|
||||
|
||||
const arrorig = await Settings.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
const arrorig = await Settings.find(myfind).lean();
|
||||
|
||||
let myarr = []
|
||||
let myarr = []
|
||||
|
||||
if (!crypted) {
|
||||
arrorig.forEach((rec) => {
|
||||
if (rec.crypted) {
|
||||
rec._doc.value_str = ''
|
||||
if (!crypted) {
|
||||
for (let rec of arrorig) {
|
||||
if (rec.crypted) {
|
||||
rec.value_str = ''
|
||||
}
|
||||
myarr.push({...rec});
|
||||
}
|
||||
myarr.push({...rec._doc});
|
||||
})
|
||||
} else {
|
||||
myarr = [...arrorig];
|
||||
} else {
|
||||
myarr = [...arrorig];
|
||||
}
|
||||
|
||||
return myarr;
|
||||
}catch (e) {
|
||||
console.error('Settings: findAllIdApp', e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return myarr;
|
||||
};
|
||||
|
||||
SettingsSchema.statics.setKeyNum = async function (idapp, key, value) {
|
||||
|
||||
@@ -61,9 +61,7 @@ TemplEmailSchema.statics.findAllIdApp = async function (idapp) {
|
||||
|
||||
const myfind = { idapp };
|
||||
|
||||
return await TemplEmail.find(myfind, (err, arrrec) => {
|
||||
return arrrec
|
||||
});
|
||||
return TemplEmail.find(myfind).lean();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user