mongoid3 - Array Creation array in mongodb -
portfolio class has array field named folders. when create using :
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} ]} ])
i got error "syntaxerror: missing ) after argument list (shell):1". guesses?
this work:
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} ]} ]})
Comments
Post a Comment