mongodump --username user --password password --db db --collection collection --query '{$and: [{"id": "ABCD"}, {"sz": {$gt: NumberLong(100)}}]}' --out dump
执行时,mongodump
抱怨:
assertion: 16619 code FailedToParse: FailedToParse: Bad characters in value: offset:63
如果我逃避$and
and$gt
子句:
mongodump --username user --password password --db db --collection collection --query '{\$and: [{"id": "ABCD"}, {"sz": {\$gt: NumberLong(100)}}]}' --out dump
相反,它会抱怨
assertion: 16619 code FailedToParse: FailedToParse: First character in field must be [A-Za-z$_]: offset:1
此查询在mongodb
shell 上成功运行,我不明白为什么不能将其--query
用作mongodump
.