我在数据库中有一个集合
c
,在 MongoDB 中名为 ftest
。已在该集合中创建一个带有 NumberLong 字段的文档,如下所示:
db.c.insert({x: NumberLong("1")})
我通过这种方式获取集合的内容(基于这种方法):
$ mongosh mongodb://localhost:27017/ftest --eval 'JSON.stringify(db.c.find().toArray(), null, " ")' --quiet
[
{
"_id": "6580316ed1c208e8c6059954",
"x": {
"low": 1,
"high": 0,
"unsigned": false
}
}
]
与 mongo 旧版 shell 的工作方式比较:
$ mongo mongodb://localhost:27017/ftest --eval 'JSON.stringify(db.c.find().toArray(), null, " ")' --quiet
[
{
"_id": {
"$oid": "6580316ed1c208e8c6059954"
},
"x": {
"$numberLong": "1"
}
}
]
所以:
low
、high
和unsigned
是什么意思?它们是否记录在某处?谢谢!
感谢@WernfriedDomscheit 反馈,使用
$ mongosh mongodb://localhost:27017/ftest --eval 'EJSON.stringify(db.c.find().toArray(), null, " ")' --quiet
我明白了
[
{
"_id": {
"$oid": "6580316ed1c208e8c6059954"
},
"x": 1
}
]
完美涵盖了我的用例。