Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

87
Vistas
Removing $or and $and assignments from pipeline in Nodejs

I'm working on updating a pipeline that isn't working properly at the moment. I'm trying to grab data that matches the following specifications, however Nodejs is 'requiring' me to use variable assignments for my different aggregations. I'm only looking to use $and at the match stage, and remove all other operators from the aggregation. The simplified match query that I've came up with looks like the following:

{
$and:[
      {templateName: 'Bug Log'},

      { 
      'classification': {
        '$elemMatch': {
          '$or': [
            {
              'name': 'Bug', 
              'value': true
            }, 
            {
              'name': 'Log', 
              'value': true
            }, 
          ]
        }
      },
},
],
}

However Nodejs if forcing a variable assignment within the function that I am using, so removing '$and' or '$or' throws an error within VScode.

        return {
            templateName: query.TEMPLATENAME,
            pipelines: {
                $and: [         //how do I remove this and block
                    {
                        ...matchPipe(id),
                    },
                    ...pipe2,
                ],
            },
        };

    return {
        classification: {
            $elemMatch: {
                $or: [ //how do i remove this $or block
                    ...args,
                ],
            },
        },
    };
}

I've gotten around the VSCode error, however the functions will treat the return statements as arrays and will replace the missing '$or'/'$and' with number values, as if it were an array or it won't allow me to perform this operation at all. I've included the returned query after removing the '$or' statement from the second return statement below for reference. How do I get around this error?

{"$and":[
{"templateName":"Bug Log","$and":[
{"classification":{"$elemMatch":{"0":{"nodePath":{}}}}},
{"classification":{"$elemMatch":{"0":{"name":"Bug"},"1":{"value":true}}}},{"classification":{"$elemMatch":{"0":{"name":"Log","value":true}}}}]}]}}

Thank you for all and any help

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda