MongoDB shell将二进制数据打印为Base64编码的字符串,该字符串封装在一个函数调用中:

"_id" : BinData(0,"e8MEnzZoFyMmD7WSHdNrFJyEk8M=")

"0"是什么意思?

推荐答案

http://docs.mongodb.org/manual/reference/mongodb-extended-json/#binary

BSON BinData数据类型通过shell中的类BinData表示.运行help misc获取更多信息.

> new BinData(2, "1234")
BinData(2,"1234")

脱壳

help misc
b = new BinData(subtype,base64str)  create a BSON BinData value

在您的 case 中,0是BSON子类型

http://bsonspec.org/#/specification

binary  ::=   int32 subtype (byte*)   Binary - The int32 is the number of bytes in the (byte*).
subtype ::=   "\x00"  Generic binary subtype
  |   "\x01"  Function
  |   "\x02"  Binary (Old)
  |   "\x03"  UUID (Old)
  |   "\x04"  UUID
  |   "\x05"  MD5
  |   "\x80"  User defined

在这个问题上也有类似的问题

http://groups.google.com/group/mongodb-dev/browse_thread/thread/1965aa234aa3ef1e

Mongodb相关问答推荐

使用mongosh将大型json文件插入到mongo集合中

使用Go的Mongo驱动程序,从MongoDB文档中获取元素并更新其值需要帮助

MongoDB - 来自先前匹配文档的聚合匹配字段

MongoDB 聚合 groupBy 日期并计算子文档

如何 db.getUser() 使用 go mongo-driver

在延迟函数中重用 context.WithTimeout

如何将交易列表变成 token 数量的对象?

将子文档中的所有字段设置为 false,然后在单个查询中将第二个字段设置为 true

mongo shell 命令不接受使用 db 命令

从嵌套数组中 id 匹配的另一个集合中获取所有字段

如何将查询结果(单个文档)存储到变量中?

Mongoose 和新架构:返回ReferenceError: Schema is not defined

字段类型在 MongoDB 索引中是否重要?

在 MongoDB 中合并两个集合

mongoose:按字母顺序排序

从 nodejs 到 mongodb 或 mongoose 的动态数据库连接

MongoDb 聚合 $match 错误:Arguments must be aggregate pipeline operators

未找到 MongoDB 数据/数据库

使用 C# 聚合 $lookup

Mongo 条件为key doesn't exist?