Mongodump文档指定可以使用特定的查询转储。
即
mongodump --host localhost --db mydb --collection testCollection --query "{SomeKey: 'some value'}"我将_ids字段存储为BinData,是否可以对此进行查询?
我试过了
mongodump --host localhost --db mydb --collection testCollection --query "{_id: 'BinData(3,ryBRQ+Px0kGRsZofJhHgqg==)'}"没有运气。
发布于 2014-01-30 16:18:02
不幸的是,这需要大量的逃避。另外,您还必须使用$binary表示。
mongodump --host localhost --db test --collection bd --query
"{\"_id\" : { \"$binary\" : \"ryBRQ+Px0kGRsZofJhHgqg==\", \"$type\" : \"03\" } }"注意,$type必须是十六进制字符串,而不是数字。
在linux中,您还必须将$转义到\$。
发布于 2014-01-31 13:21:46
你不需要逃避那么多。您可以在查询之外使用单引号,在查询中使用双引号,但要注意类型为十六进制,意思是"03“而不是"3”。
mongodump --host localhost --db test --collection bd --query
'{"_id" : { "$binary" : "ryBRQ+Px0kGRsZofJhHgqg==", "$type" : "03" } }'https://stackoverflow.com/questions/21461060
复制相似问题