Arrays MongoDB。属性名称中缺少“]
您好,我有一本藏书,我想在其中插入一系列文档:Arrays MongoDB。属性名称中缺少“],arrays,mongodb,collections,insert,database,Arrays,Mongodb,Collections,Insert,Database,您好,我有一本藏书,我想在其中插入一系列文档: > db.book.insert({[ {x:null},{y:true},{a:3.23},{b:'abc'}, {c:new Date()},{d:[1,2,3]}, {f:1} ]}) 它给了我这个错误: 2016-03-06T00:53:58.893+0300 E QUERY [thread1] **SyntaxError: missing ] in computed property name @(shell):1:2
> db.book.insert({[ {x:null},{y:true},{a:3.23},{b:'abc'},
{c:new Date()},{d:[1,2,3]}, {f:1} ]})
它给了我这个错误:
2016-03-06T00:53:58.893+0300 E QUERY
[thread1] **SyntaxError: missing ] in computed property name @(shell):1:27**
我看不到丢失的“]”,这是我的错吗
我想同时添加7个文档
我需要在一个数组中包含所有文档,对吗.insert({[…]})
如您所见,文档'd'也是一个数组。通过删除'()'中的'{}'来解决: 最终结果:
db.book.insert([ {x:null},{y:true},{a:3.23},{b:'abc'},
{c:new Date()},{d:[1,2,3]}, {f:1} ])
它将是
db.book.insert([{“x”:null},{“y”:true}])
。您将方括号[]
“放在”花括号{}
内。它的意思是“外面”成为“名单”,你是对的!非常感谢。