emilsoftware-utilities 1.4.0-dev.15 → 1.4.0-dev.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -387,12 +387,21 @@ let UserService = class UserService {
|
|
|
387
387
|
return;
|
|
388
388
|
}
|
|
389
389
|
yield this.executeInTransaction(() => __awaiter(this, void 0, void 0, function* () {
|
|
390
|
-
|
|
391
|
-
const
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
390
|
+
// Prima verifichiamo se esiste il record
|
|
391
|
+
const checkQuery = `SELECT COUNT(*) as CNT FROM FILTRI WHERE CODUTE = ?`;
|
|
392
|
+
const existingRecord = yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, checkQuery, [
|
|
393
|
+
codiceUtente,
|
|
394
|
+
]);
|
|
395
|
+
const exists = existingRecord[0].CNT > 0;
|
|
396
|
+
if (exists) {
|
|
397
|
+
// Se esiste, facciamo l'UPDATE
|
|
398
|
+
const updates = fieldsToUpdate.map((f) => `${f.dbField} = ?`).join(', ');
|
|
399
|
+
const values = [...fieldsToUpdate.map((f) => f.value), codiceUtente];
|
|
400
|
+
const updateQuery = `UPDATE FILTRI SET ${updates} WHERE CODUTE = ?`;
|
|
401
|
+
yield Orm_1.Orm.execute(this.accessiOptions.databaseOptions, updateQuery, values);
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
// Se non esiste, facciamo l'INSERT
|
|
396
405
|
const dbFields = ['CODUTE', ...fieldsToUpdate.map((f) => f.dbField)];
|
|
397
406
|
const placeholders = dbFields.map(() => '?');
|
|
398
407
|
const insertValues = [codiceUtente, ...fieldsToUpdate.map((f) => f.value)];
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|