Search code examples
mongodbmongoexport

Mongoexport date range query result in Failure parsing


Trying to run mongoexport and having problems with my query parameter.

mongoexport -d test-copy  -c collection -o /home/ubuntu/mongodb-archiving/mongodump/collection.json --query '{"created_at": {\$lte: new Date(1451577599000) } }'

Collection is:

{"created_at" : ISODate("2014-03-07T06:32:19.172Z")}

To which I can query just fine in Mongo Client.

The result in the following error:

Assertion: 10340:Failure parsing JSON string near: "created_a


Solution

  • You have a \ in your query. Please remove it.

    --query '{"created_at": {$lte: new Date(1451577599000)}}'