- corretto cancellazione ordine

This commit is contained in:
Surya Paolo
2024-02-15 18:58:58 +01:00
parent 24f2b46cc8
commit 6e61138fde
4 changed files with 85 additions and 17 deletions

View File

@@ -19,7 +19,7 @@ const Order = require('../models/order');
const Variant = require('../models/variant');
const { User } = require('../models/user');
const {ObjectID} = require('mongodb');
const { ObjectID } = require('mongodb');
/*const Department = require('../models/Department')
const Category = require('../models/Category')
@@ -489,20 +489,6 @@ router.post('/:userId/gestord', authenticate, async function (req, res, next) {
preserveNullAndEmptyArrays: true,
},
},
{
$match: {
$or: [
{
'gasordine.active': true,
},
{
gasordine: {
$exists: false,
},
},
],
},
},
{
$match: {
$or: [
@@ -519,6 +505,21 @@ router.post('/:userId/gestord', authenticate, async function (req, res, next) {
],
},
},
{
$lookup: {
from: "orderscarts",
localField: "_id",
foreignField: "items.order",
as: "matchingOrders",
},
},
{
$match: {
"matchingOrders": {
$ne: [],
},
},
},
{
$group: {
_id: '$product._id',