Corretto Ordini e visualizzazione dei Totali

This commit is contained in:
Surya Paolo
2023-12-15 21:50:21 +01:00
parent 05ec283882
commit 4d9eccd1ae
10 changed files with 326 additions and 314 deletions

View File

@@ -180,30 +180,33 @@ module.exports.getOrderByID = function (id, callback) {
}
module.exports.createOrder = async function (order) {
const orderModel = new Order(order);
return await orderModel.save(order)
.then((ris) => {
if (!!ris)
return ris._id;
return null;
});
try {
return await Order.create(order)
.then((ris) => {
if (!!ris)
return ris._id;
return null;
});
} catch (e) {
console.error('err', e);
}
}
module.exports.updateStatusOrders = async function (arrOrders, status) {
for (const order of arrOrders) {
const ret = await this.findOneAndUpdate({ _id: order._id }, { $set: status });
}
}
module.exports.updateStatusOrdersElements = async function (arrOrders, myelements) {
for (const order of arrOrders) {
const ret = await this.findOneAndUpdate({ _id: order._id }, { $set: myelements });
}
}
module.exports.getTotalOrderById = async function (id) {