- Cataloghi: parte finale... prima bozza 9 dic
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user