- le categorie visibili solo se ci sono prodotti attivi
This commit is contained in:
@@ -580,23 +580,46 @@ module.exports.convertAfterImportALLPROD = async function (idapp, dataObjects) {
|
|||||||
module.exports.getArrCatProds = async function (idapp, cosa) {
|
module.exports.getArrCatProds = async function (idapp, cosa) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let addquery = {};
|
let addquery = [];
|
||||||
let arr = [];
|
let arr = [];
|
||||||
if (cosa === shared_consts.PROD.GAS) {
|
if (cosa === shared_consts.PROD.GAS) {
|
||||||
addquery = { idapp, idGasordine: { $exists: true, $ne: null, $type: 'objectId' } }
|
addquery = [
|
||||||
|
{ $match: { idapp, idGasordine: { $exists: true, $ne: null, $type: 'objectId' } } }
|
||||||
|
];
|
||||||
|
|
||||||
|
addquery.push(
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: 'gasordines',
|
||||||
|
localField: 'idGasordine',
|
||||||
|
foreignField: '_id',
|
||||||
|
as: 'gasordine'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
addquery.push(
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
"gasordine.active": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
} else if (cosa === shared_consts.PROD.BOTTEGA) {
|
} else if (cosa === shared_consts.PROD.BOTTEGA) {
|
||||||
addquery = {
|
addquery = [{
|
||||||
|
$match: {
|
||||||
idapp, $or: [
|
idapp, $or: [
|
||||||
{ idGasordine: { $exists: false } },
|
{ idGasordine: { $exists: false } },
|
||||||
{ idGasordine: { $exists: true, $eq: null } }
|
{ idGasordine: { $exists: true, $eq: null } }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
}]
|
||||||
} else {
|
} else {
|
||||||
addquery = { idapp };
|
addquery = [{ $match: { idapp } }];
|
||||||
}
|
}
|
||||||
|
|
||||||
let myquery = [
|
let myquery = [...addquery,
|
||||||
{ $match: addquery },
|
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: "productinfos",
|
from: "productinfos",
|
||||||
|
|||||||
Reference in New Issue
Block a user