使用BinData查询MongoDump [英] MongoDump query with BinData

查看:62
本文介绍了使用BinData查询MongoDump的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Mongodump文档指定您可以使用特定查询进行转储

The Mongodump documentation specifies you can dump using a specific query

mongodump --host localhost --db mydb --collection testCollection --query "{SomeKey: 'some value'}"

我将_ids字段存储为BinData,是否可以对此进行查询?

I'm storing _ids fields as BinData, is it possible to query on this?

我尝试过

mongodump --host localhost --db mydb --collection testCollection --query "{_id: 'BinData(3,ryBRQ+Px0kGRsZofJhHgqg==)'}"

没有运气.

推荐答案

不幸的是,这需要大量转义.另外,您还必须使用 $binary 表示形式,例如

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\" } }"

请注意,$type必须是十六进制字符串,而不是数字.

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

在linux中,您还必须将$转为\$.

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

这篇关于使用BinData查询MongoDump的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆