如何在MongoDB中插入长号?
要插入长号,请使用NumberLong()。它用于处理64位整数。让我们创建一个包含文档的集合-
> db.demo273.insert({
... Name:"Robert",
... id: NumberLong("100000000000001"),
... isActive:true
...})
WriteResult({ "nInserted" : 1 })
> db.demo273.insert({
... Name:"David",
... id: NumberLong("98888888888888888"),
... isActive:false
...})
WriteResult({ "nInserted" : 1 })
> db.demo273.insert({
... Name:"Mike",
... id: NumberLong("999999999999"),
... isActive:true
...})
WriteResult({ "nInserted" : 1 })在find()方法的帮助下显示集合中的所有文档-
> db.demo273.find();
输出结果
这将产生以下输出-
{ "_id" : ObjectId("5e4824df1627c0c63e7dbac3"), "Name" : "Robert", "id" : NumberLong("100000000000001"), "isActive" : true }
{ "_id" : ObjectId("5e4824e01627c0c63e7dbac4"), "Name" : "David", "id" : NumberLong("98888888888888888"), "isActive" : false }
{ "_id" : ObjectId("5e4824e11627c0c63e7dbac5"), "Name" : "Mike", "id" : NumberLong("999999999999"), "isActive" : true }热门推荐
10 医院探望朋友祝福语简短
11 毕业祝福语简短女朋友
12 春节虎年爸妈祝福语简短
13 儿童毕业祝福语 简短6
14 开工仪式横幅祝福语简短
15 孩子日常祝福语大全简短
16 清晨寄语诗句祝福语简短
17 结婚送亲认亲祝福语简短
18 虎年喝酒拜年祝福语简短