- filtro se GAS o Prodotti
This commit is contained in:
@@ -188,73 +188,67 @@ module.exports.getOrdersCartByQuery = async function (query) {
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idProduct',
|
||||
model: 'Product'
|
||||
},
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idProduct',
|
||||
model: 'Product',
|
||||
populate: {
|
||||
path: 'idProductInfo',
|
||||
model: 'ProductInfo'
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idProducer',
|
||||
model: 'Producer'
|
||||
},
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idProvider',
|
||||
model: 'Provider'
|
||||
},
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idGasordine',
|
||||
model: 'Gasordine'
|
||||
},
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idStorehouse',
|
||||
model: 'Storehouse'
|
||||
},
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'items.order',
|
||||
populate: {
|
||||
path: 'idScontisticas',
|
||||
model: 'Scontistica'
|
||||
},
|
||||
}
|
||||
})
|
||||
.populate({
|
||||
path: 'userId',
|
||||
model: 'User',
|
||||
select: '_id name surname username profile', // Specify the fields you want to retrieve
|
||||
select: '_id name surname username profile'
|
||||
})
|
||||
.lean();
|
||||
|
||||
myorderscart = myorderscart.map(order => {
|
||||
order.user = order.userId
|
||||
order.userId = order.user._id
|
||||
order.user = order.userId;
|
||||
order.userId = order.user._id;
|
||||
order.items = order.items.map(item => {
|
||||
if (item.order) {
|
||||
try {
|
||||
item.order.product = item.order.idProduct;
|
||||
item.order.idProduct = item.order.product ? item.order.product._id : '';
|
||||
if (item.order.product.idProductInfo) {
|
||||
item.order.product.productInfo = item.order.product.idProductInfo;
|
||||
item.order.product.idProductInfo = item.order.product ? item.order.product.productInfo._id : '';
|
||||
if (item.order.idProduct) {
|
||||
item.order.idProduct.productInfo = item.order.idProduct.productInfo ? item.order.idProduct.productInfo : {...item.order.idProduct.idProductInfo};
|
||||
item.order.idProduct.idProductInfo = item.order.idProduct.productInfo ? item.order.idProduct.productInfo._id : '';
|
||||
}
|
||||
item.order.product = {...item.order.idProduct};
|
||||
item.order.idProduct = item.order.product ? item.order.product._id : '';
|
||||
item.order.producer = item.order.idProducer;
|
||||
item.order.idProducer = item.order.producer ? item.order.producer._id : '';
|
||||
item.order.storehouse = item.order.idStorehouse;
|
||||
@@ -274,6 +268,7 @@ module.exports.getOrdersCartByQuery = async function (query) {
|
||||
return order;
|
||||
});
|
||||
|
||||
|
||||
return myorderscart;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user