Question

Portfolio class has an array field named folders. when i create it 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 that "SyntaxError: missing ) after argument list (shell):1". Any guesses?

Was it helpful?

Solution

This will 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}
    ]}
]})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top