问题描述
我的 MongoDB 数据库中有两个文档。它们是(简化):
{
"_id" : "ONE","items": [
42,0
]
}
{
"_id" : "TWO","items": [
0,0
]
}
它们是由客户端应用程序(即不使用 MongoDB shell)创建的,我怀疑其行为(我的意思是,应用程序可能有错误,我正在尝试对其进行调试)。
我怀疑文档 ONE
将 items
中的数字编码为 BSON 级别的 32 位整数(即 BSON type 16),而在文档 TWO
中它们被编码在双(即BSON type 1)
我尝试在 MongoDB shell 中使用 JavaScript 中常用的 typeof
运算符检查它,但似乎它们没有检测到任何差异:
> typeof db.entities.find({_id: "ONE"})[0].items[0]
number
> typeof db.entities.find({_id: "ONE"})[0].items[1]
number
> typeof db.entities.find({_id: "TWO"})[0].items[0]
number
> typeof db.entities.find({_id: "TWO"})[0].items[1]
number
是否有任何精确的方法可以从 MongoDB shell 中知道给定的 MongoDB 文档片段的 BSON 类型?
提前致谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)