Reputation: 31
I am exporting mongodb collection to csv which works fine and dumps "1000" records.
mongoexport --port=<id> --db=<name> --collection=<table-name> --type=csv --fields=<field-name> --out <file-name> --limit 1000
But I want to dump records within a specific timeframe, that is, dump all records with timestamp that match the given timeframe. I could not find any documentation on how to do the same?
Is there a way to do the same?
Upvotes: 3
Views: 475
Reputation: 36134
You can use --query option to pass query in JSON format,
--query '{ "Date": { "$gt": { "$date": "2021-01-02T07:00:00.000Z" }, "$lt": "2021-01-02T10:00:00.000Z" } }'
Upvotes: 2