Portfolio类有一个名为folders的数组字段。当我用它创建它时:
db.portfolio.insert(
folders: [
{"name"=>"Folder 1",
"stocks"=>[
{"name"=>"stock name",
"id"=>"stock id1",
"qty"=>2},
{"name"=>"stock name",
"id"=>"stock id2",
"qty"=>1}
]},
{"name"=>"Folder 2",
"stocks"=>[
{"name"=>"stock name",
"id"=>"stock id3",
"qty"=>2},
{"name"=>"stock name",
"id"=>"stock id4",
"qty"=>1}
]}
])
我在参数列表(shell)之后得到“SyntaxError:missing”的错误:1“。任何猜测?
答案 0 :(得分:1)
这将有效:
db.portfolio.insert({
folders: [
{"name":"Folder 1",
"stocks":[
{"name":"stock name",
"id":"stock id1",
"qty":2},
{"name":"stock name",
"id":"stock id2",
"qty":1}
]},
{"name":"Folder 2",
"stocks":[
{"name":"stock name",
"id":"stock id3",
"qty":2},
{"name":"stock name",
"id":"stock id4",
"qty":1}
]}
]})