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

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -