import dati prodotti + fornitore + produttore
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' },
|
||||
idProvider: { type: Schema.Types.ObjectId, ref: 'Provider' },
|
||||
price: {
|
||||
type: Number
|
||||
},
|
||||
@@ -148,8 +149,17 @@ module.exports.findAllIdApp = async function (idapp) {
|
||||
as: 'producer'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'providers',
|
||||
localField: 'idProvider',
|
||||
foreignField: '_id',
|
||||
as: 'provider'
|
||||
}
|
||||
},
|
||||
{ $unwind: '$product' },
|
||||
{ $unwind: '$producer' },
|
||||
{ $unwind: '$provider' },
|
||||
];
|
||||
|
||||
return await Order.aggregate(query)
|
||||
@@ -223,9 +233,18 @@ module.exports.getTotalOrderById = async function (id) {
|
||||
as: 'storehouse'
|
||||
}
|
||||
},
|
||||
{
|
||||
$lookup: {
|
||||
from: 'providers',
|
||||
localField: 'idProvider',
|
||||
foreignField: '_id',
|
||||
as: 'provider'
|
||||
}
|
||||
},
|
||||
{ $unwind: '$product' },
|
||||
{ $unwind: '$producer' },
|
||||
{ $unwind: '$storehouse' },
|
||||
{ $unwind: '$provider' },
|
||||
];
|
||||
|
||||
return await Order.aggregate(query);
|
||||
|
||||
Reference in New Issue
Block a user