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

224
Views
Aggregate Function is not working with parameter

I was getting MongoDB data. If I use the JavaScript parameter while retrieving data from MongoDB it returns null, if I type it manually it returns all the data without issue. That's working

const data = await NumbersModel.aggregate([{
  $project: {
    Datas: {
      $filter: {
        input: "$Datas",
        as: "data",
        cond: {
          $gte: ["$$data.time", 0]
        }
      }
    }
  }
}])
res.send(data)

That's not working

if (req.query.lasttimestamp === null) return res.send(`cannot be empty`)
        let lasttimestamp = req.query.lasttimestamp
        const data = await NumbersModel.aggregate([
            {
                $project: {
                    Datas: {
                        $filter: {
                            input: "$Datas",
                            as: "data",
                            cond: { $gte: [ "$$data.time", lasttimestamp ] }
                        }
                    }
                }
            }
        ])
    res.send(data)
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The values in req.query are strings. You want to convert it to a number:

let lasttimestamp = parseInt(req.query.lasttimestamp);
over 4 years ago · Santiago Trujillo Report
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!