Metabase fails on new ISODate() mongo native query


OS: Ubuntu 16.04
Metabase version: 0.29.3

I am running an aggregation pipeline for mongo, where I’m trying to look at all the datapoints in the past X days.
Due to the nature of the data, I need to run it in a JSON mongo query. The step that is failing looks like this:

    {"$lt": new ISODate(), 
     "$gte": new ISODate(new ISODate().setDate(new ISODate().getDate()-30))}}}

and I am getting the following error:

Unrecognized token 'new': was expecting 'null', 'true', 'false' or NaN at [Source:; line: 37, column: 21]

The problem is obviously the first call to new ISODate().

I have found several (; other github bug reports regarding this and they appear as fixed and merged, yet I cannot do it…

Am I doing something wrong, or is it actually a feature that’s not (yet) supported?


I’m not a MongoDB user myself, but searching for ISODate here gives several examples of MongoDB ISODate() queries without the new keyword. What happens if you drop the news in your query?


Good point and I have tried that too:

    {"$lt": ISODate(), 
     "$gte": ISODate(ISODate().setDate(ISODate().getDate()-30))

and I get the following error:

Unexpected character (’.’ (code 46)): was expecting comma to separate Array entries at
[; line: 37, column: 48]

It does not interpret “.” correctly, and that seems to happen with operations ("-") as well.
However, using just ISODate() does seem to work if I only have this matching code:

{"$lt": ISODate()}

but this is kind of useless, since I need a way to set dates relative to the present moment.
I’m sure I could hardcode the dates every time I need the query, but that defeats the purpose of making it automatic…