Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

81
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda