MongoDump query with BinData

前端 未结 2 1246
一个人的身影
一个人的身影 2021-01-13 03:46

The Mongodump documentation specifies you can dump using a specific query

i.e.

mongodump --host localhost --db mydb --collection testCollection --que         


        
相关标签:
2条回答
  • 2021-01-13 03:58

    This needs a lot of escaping, unfortunately. Also, you'll have to use the $binary representation instead, e.g.

    mongodump --host localhost --db test --collection bd --query 
    "{\"_id\" : { \"$binary\" : \"ryBRQ+Px0kGRsZofJhHgqg==\", \"$type\" : \"03\" } }"
    

    Note that $type must be a hex string, not a number.

    In linux, you'll also have to escape the $ to \$.

    0 讨论(0)
  • 2021-01-13 04:14

    You don't need to escape that much. You may just use single-quote outside of the query and double-quote inside, i.e. But beware to have the type as hex, meaning "03" and not "3"

    mongodump --host localhost --db test --collection bd --query
    '{"_id" : { "$binary" : "ryBRQ+Px0kGRsZofJhHgqg==", "$type" : "03" } }'
    
    0 讨论(0)
提交回复
热议问题