Corretto Duplicazione Sito (es: da 1 a 14)

This commit is contained in:
Paolo Arena
2022-05-14 00:31:53 +02:00
parent 6bee532b9b
commit bedd724523
12 changed files with 72 additions and 46 deletions

View File

@@ -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) {