- Cataloghi: parte finale... prima bozza 9 dic

This commit is contained in:
Surya Paolo
2024-12-09 12:32:09 +01:00
parent 8803190313
commit 14bca3e282
5 changed files with 78 additions and 24 deletions

View File

@@ -841,7 +841,7 @@ async function duplicatePage(pageId, newpath) {
_id: new mongoose.Types.ObjectId(), // Genera un nuovo ID
// modifiche ai campi se necessario, per esempio:
path: newpath,
title: newpath,
title: newpath,
date_updated: new Date()
});
@@ -935,7 +935,7 @@ router.patch('/chval', authenticate, async (req, res) => {
try {
const mytable = globalTables.getTableByTableName(mydata.table);
const fieldsvalue = mydata.fieldsvalue;
let fieldsvalue = mydata.fieldsvalue;
const unset = mydata.unset;
const { Account } = require('../models/account');
@@ -1032,6 +1032,21 @@ router.patch('/chval', authenticate, async (req, res) => {
precRec = await mytable.findById(id);
}
if (mydata.table === 'arrvariazioni') {
let chiave = null;
let valore = null;
for (const [key, value] of Object.entries(fieldsvalue)) {
chiave = key;
valore = value;
}
if (chiave) {
// Costruiamo la stringa di assegnazione dinamica
fieldsvalue = { [`arrvariazioni.0.${chiave}`]: valore };
}
}
return await mytable.findByIdAndUpdate(id, { $set: fieldsvalue }, { new: true }).
then(async (rec) => {
// tools.mylogshow(' REC TO MODIFY: ', rec);