title: Multidimensional addToSet / Push mongodb
body: <p>I want to create a multidimensional collection.
  The collection has locations. Each locations has users and each user has photos.</p>
  
  <p>Right now the collection has locations e.g.</p>
  
  <pre><code>{ "_id" : ObjectId( "52148266c36b4403e855bef9" ),
    "latitude" : 48.958,
    "id" : "110600715",
    "longitude" : 9.13,
    "name" : "Coffee" }
  </code></pre>
  
  <p>My final result need to be something like:</p>
  
  <pre><code>{ "_id" : ObjectId( "52148266c36b4403e855bef9" ),
    "latitude" : 48.958,
    "id" : "110600715",
    "longitude" : 9.13,
    "name" : "Coffee", 
    'users' : [
          {
          'user' : 45,
          'username' : 'Me',
          'user_fullname': 'Name Lastname',
          'photos': [
              {
              'photo_id' : 10,
              'created_time' : 1236456712,
              'link' : 'http...',
              'image' : 'http...',
              'tags' : 'a'
              },
              {...}
              ] # end of photos list
          },
          {...}
          ] #end of users list
  }
  </code></pre>
  
  <p>If the user does not exist create new user and add the first picture.
  If the user exists add the next picture with unique <code>photo_id</code>.</p>
  
  <p>This is a sample I tried the following. I am using <em>pymongo</em> with python. I know I am missing a second <code>$addToSet</code> or something similar.</p>
  
  <pre><code>db.col.update( {'_id':location_id['_id']},
              { '$addToSet' : 
                  { 
                  'user' : int(i['user']['id']),
                  'username' : i['user']['username'],
                  'user_fullname': i['user']['full_name'],
                  'photos':
                      {
                      'photo_id' : i['id'],                                   
                      'created_time' : int(i['created_time']),
                      'link' : i['link'],
                      'image' : i['images']['url'],
                      'tags' : i['tags']
                      }
                  }
              }
          )
  </code></pre>