aggiornamento scontistica, corretto errori
This commit is contained in:
@@ -25,6 +25,7 @@ const orderSchema = new Schema({
|
||||
idProduct: { type: Schema.Types.ObjectId, ref: 'Product' },
|
||||
idProducer: { type: Schema.Types.ObjectId, ref: 'Producer' },
|
||||
idStorehouse: { type: Schema.Types.ObjectId, ref: 'StoreHouse' },
|
||||
idScontisticas: [{ type: Schema.Types.ObjectId, ref: 'Scontistica' }],
|
||||
idProvider: { type: Schema.Types.ObjectId, ref: 'Provider' },
|
||||
price: {
|
||||
type: Number
|
||||
@@ -167,13 +168,23 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$scontistica',
|
||||
path: '$product',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{ $unwind: '$product' },
|
||||
{ $unwind: '$producer' },
|
||||
{ $unwind: '$provider' },
|
||||
{
|
||||
$unwind: {
|
||||
path: '$producer',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$provider',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
}
|
||||
|
||||
];
|
||||
|
||||
return await Order.aggregate(query)
|
||||
@@ -263,19 +274,33 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
from: 'scontisticas',
|
||||
localField: 'idScontisticas',
|
||||
foreignField: '_id',
|
||||
as: 'scontistica'
|
||||
as: 'scontisticas'
|
||||
}
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$scontistica',
|
||||
path: '$product',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{ $unwind: '$product' },
|
||||
{ $unwind: '$producer' },
|
||||
{ $unwind: '$storehouse' },
|
||||
{ $unwind: '$provider' },
|
||||
{
|
||||
$unwind: {
|
||||
path: '$producer',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$storehouse',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
$unwind: {
|
||||
path: '$provider',
|
||||
preserveNullAndEmptyArrays: true,
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
return await Order.aggregate(query);
|
||||
|
||||
Reference in New Issue
Block a user