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

484
Views
Alternative to Mongo $where that errors out in PDI?

This criteria featuring a $where clause which uses JavaScript works fine at the command prompt, for example when enclosed in db.mycollection.find(). By that I mean it returns matching records where test field has value "true" and dateTime field which is in epoch milliseconds has value that falls within the previous day...

{$and:[{test:"true",$where: function(){return (new Date(this.dateTime + 86400000) < new Date())}}]}

...but in PDI CE 8, it throws an error com.mongodb.util.JSONParseException and points at the u in function, for example, when used as criteria in a "MongoDB input" step for deleting records.

I couldn't find the reason specifically, but I believe function (and aggregation and probably many others) cannot be used as matching criteria via PDI (nor via MongoDB Compass). This seems to be a point of general confusion on the internet about two different species of "mongo commands". Any guidance that explains that in a plain way could be very helpful to predict which is which, to prevent wasting time developing with the wrong species (maybe "Avoid anything with parentheses in criteria" is the rule?), but my main question is...

Is there an alternative mongo criteria I could use to accomplish the same goal?

about 4 years ago · Juan Pablo Isaza
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!