Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

86
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!