import dati prodotti + fornitore + produttore

This commit is contained in:
Surya Paolo
2023-12-15 00:57:14 +01:00
parent ea2b7095c9
commit 05ec283882
8 changed files with 223 additions and 33 deletions

View File

@@ -35,6 +35,7 @@ router.post('/updateval', authenticate, async (req, res) => {
router.post('/import', authenticate, async (req, res) => {
const cmd = req.body.cmd;
const idapp = req.body.idapp;
const data = req.body.data;
try {
@@ -49,15 +50,23 @@ router.post('/import', authenticate, async (req, res) => {
let dataObjects = JSON.parse(`[${data}]`);
return await Product.insertMany(dataObjects).then((ris) => {
// L'opzione ordered: false gestisce gli errori senza interrompere l'inserimento
return await Product.insertMany(dataObjects, { ordered: false })
.then((ris) => {
Product.convertAfterImport().then((ris) => {
return res.status(200).send(true);
Product.convertAfterImport(idapp, dataObjects).then((ris) => {
return res.status(200).send(true);
});
})
.catch((errors) => {
console.error(errors);
Product.convertAfterImport(idapp).then((ris) => {
return res.status(200).send(true);
});
});
});
}
} catch (e) {
console.error('e', e);