简体   繁体   中英

mongodb mongodump json parse error on date field

I have this query, which generates 10340 Failure parsing JSON string near: my_da error. If I change the conditioanal from reading_Date to another field with a baisc match, it works. There something going on when it parses the JSON date..

sudo bin/mongodump --db myDB --collection myColl -q "{my_date: {$gte: {Date(1341230400000)}}}" --out - > dump/myDB/will.bson

Could someone lend a hand?

The reading_date is stored in ISODate format as: "my_date" : ISODate("2011-08-31T12:00:00Z")

Thanks!

Try this:

$ mkdir dump
$ mongodump -d myDB -c myColl -q "{my_date: {\$gte: { \$date: 1341230400000 } }}" -o dump/

$date is the JSON representation of a 64 bit signed integer for milliseconds since epoch (unsigned before version 1.9.1). Mongo Extended JSON

Also the operator $ was escaped

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM