title: MongoDb : How to insert additional object into object collection?
body: <p>I have a document "owner" that can have "n" number of camps and camps have "instructors" and instructors have "classes". Earlier I tried accomplishing this with nested arrays (see link to my post below), however I learned that the positional operator "$" does not nest that deep.
  <a href="https://stackoverflow.com/questions/17267213/mongodb-adding-an-array-into-an-existing-array">MongoDB: Adding an array into an existing array</a></p>
  
  <p>However, I learned that the workaround would be to use object collections instead of arrays. I'm assuming that I have to use "update" with "$set" to add additional "camps", however every time I do all it does is overwrite(update) the previous camp that was inserted.</p>
  
  <p>Below is the hierarchical structure I am trying to accomplish:</p>
  
  <pre><code>owner = {
  
      firstName: 'john',
      lastName: 'smith',
      ownerEmail: 'john.smith@gmail.com',
  
      camps : {
  
          {
              name: 'cubs-killeen',
              location: 'killeen'
          },
  
          {
              name: 'cubs-temple',
              location: 'temple'
          },
  
          instructors : {
  
              {
                  firstName: 'joe',
                  lastName : 'black'
              },
  
              {
                  firstName: 'will',
                  lastName : 'smith'
              }        
          }
  
      }
  
  }
  </code></pre>
  
  <p>I have also been trying the following: </p>
  
  <pre><code>db.owners.update({ownerEmail:'john.smith@gmail.com'}, {$set: { camps:{ {name:'cubs-killeen'} } }})
  </code></pre>
  
  <p>but this throws an unexpected identifier { error.</p>
  
  <p>Any help with some sample mongo commands to achieve the structure above would be most appreciated.</p>
  
  <p>V/R</p>
  
  <p>Chris</p>