ver 1.1.20:

- corretto campo foto che non compariva più.
 - sistemato i campi aggiuntivi e i richiesti.
- migliorato la barra in alto di selezione.
- aggiunto alcune icone.
This commit is contained in:
Surya Paolo
2025-02-03 17:18:27 +01:00
parent 341b4b8ec7
commit 41d5f562ec
21 changed files with 292 additions and 298 deletions

View File

@@ -30,7 +30,7 @@ module.exports = {
},
async insertIntoDb_NoDuplicate(attiva, tablename, table, field) {
async insertIntoDb_NoDuplicate(attiva, tablename, table, field, field2) {
let numrec = 0;
let numupdated = 0;
try {
@@ -43,7 +43,10 @@ module.exports = {
if (mydbfile && mydbfile.list) {
for (const rec of mydbfile.list) {
let query = {};
query[field] = rec[field];
if (field)
query[field] = rec[field];
if (field2)
query[field2] = rec[field2];
if (rec.hasOwnProperty('_id')) {
query._id = rec._id;
@@ -57,6 +60,8 @@ module.exports = {
const existingDoc = await table.findOne(query);
if (!existingDoc) {
console.log('ADD: ' + query);
const { value: existingDoc, upserted } = await table.findOneAndUpdate(
query,
{ $set: rec },
@@ -71,8 +76,9 @@ module.exports = {
} else {
// Il documento esiste, lo aggiorniamo
await table.updateOne({ _id: existingDoc._id }, { $set: rec });
numupdated++;
const ris = await table.updateOne({ _id: existingDoc._id }, { $set: rec });
if (ris && ris.nModified > 0)
numupdated++;
}
} catch (e) {
console.log('Error processing record:', e);
@@ -172,8 +178,7 @@ module.exports = {
if (rec.table === 'contribtypes') {
attiva = scrivi_contribtype;
}
await this.insertIntoDb_NoDuplicate(attiva, rec.table, mytable, rec.key);
await this.insertIntoDb_NoDuplicate(attiva, rec.table, mytable, rec.key, rec.key2);
}
console.log('FINE - popolaTabelleNuove');