'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?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
