mongodump with a conditional date range

If you are using mongodump and want to use conditions to get a partial data export, there are some gotchas when it comes to date.

A query like

{receivedOn : { $gte : ISODate("2018-04-05 10:44:00.344Z") } }

has to morph into

--query='{receivedOn : { $gte : { $date : "2018-04-05T10:44:00.344Z"} } }'

This is in accordance with the extended JSON format of MongoDB.

 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.