mongorestore filter ISODate gives error

262 views Asked by At

I have this query

mongorestore  --db xxx --collection categories  --filter '{"creation_date": {"$gt": ISODate("2015-06-06T20:00:00Z")}}' /backups/xxx/dump/xxx/xxx.bson

And have this error

assertion: 16619 code FailedToParse: FailedToParse: Bad characters in value: offset:25 of:{"creation_date": {"$gt": ISODate("2015-06-06T20:00:00Z")}}

I think mongorestore is not happy with ISODate, any ideas?

1

There are 1 answers

0
totymedli On

Use the version for strict mode

I had the same problem then I found this GitHub issue that points to this JIRA issue that states, that we can use {"$date": "2015-06-06T20:00:00Z"} instead of ISODate("2015-06-06T20:00:00Z") so your query should look like this:

mongorestore --db xxx --collection categories --filter '{"creation_date": {"$gt": {"$date": "2015-06-06T20:00:00Z"}}}' /backups/xxx/dump/xxx/xxx.bson

This feature is documented in MongoDB Extended JSON.