++GasOrdini

This commit is contained in:
Surya Paolo
2023-12-21 02:23:52 +01:00
parent 2ab4bd4e2a
commit 000e900f48
6 changed files with 128 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ const orderSchema = new Schema({
idStorehouse: { type: Schema.Types.ObjectId, ref: 'StoreHouse' },
idScontisticas: [{ type: Schema.Types.ObjectId, ref: 'Scontistica' }],
idProvider: { type: Schema.Types.ObjectId, ref: 'Provider' },
idGasordine: { type: Schema.Types.ObjectId, ref: 'Gasordine' },
price: {
type: Number,
default: 0,
@@ -169,6 +170,14 @@ module.exports.findAllIdApp = async function (idapp) {
as: 'provider'
}
},
{
$lookup: {
from: 'gasordines',
localField: 'idGasordine',
foreignField: '_id',
as: 'gasordine'
}
},
{
$lookup: {
from: 'scontisticas',
@@ -194,6 +203,12 @@ module.exports.findAllIdApp = async function (idapp) {
path: '$provider',
preserveNullAndEmptyArrays: true,
},
},
{
$unwind: {
path: '$gasordine',
preserveNullAndEmptyArrays: true,
},
}
];
@@ -346,6 +361,14 @@ module.exports.getTotalOrderById = async function (id) {
as: 'provider'
}
},
{
$lookup: {
from: 'gasordines',
localField: 'idGasordine',
foreignField: '_id',
as: 'gasordine'
}
},
{
$lookup: {
from: 'scontisticas',
@@ -378,6 +401,12 @@ module.exports.getTotalOrderById = async function (id) {
preserveNullAndEmptyArrays: true,
},
},
{
$unwind: {
path: '$gasordine',
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: 'orders',