mongodump --username user --password password --db db --collection collection --query '{$and: [{"id": "ABCD"}, {"sz": {$gt: NumberLong(100)}}]}' --out dump
When executed, mongodump
complained with:
assertion: 16619 code FailedToParse: FailedToParse: Bad characters in value: offset:63
If I escape the $and
and $gt
clauses:
mongodump --username user --password password --db db --collection collection --query '{\$and: [{"id": "ABCD"}, {"sz": {\$gt: NumberLong(100)}}]}' --out dump
It will instead complain with
assertion: 16619 code FailedToParse: FailedToParse: First character in field must be [A-Za-z$_]: offset:1
This query runs successfully on mongodb
shell, I can't see why I can't use it as a --query
parameter in mongodump
.