import dati prodotti + fornitore + produttore
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user