title: What does update() in mongodb returns
body: <p>While writing python script for the api in mongodb..</p>
  
  <p>We have..</p>
  
  <pre><code>new_posts = [{ 'name': 'A', 'age': 17, 'marks': 97, 'school': 'School1' },
               { 'name': 'B', 'age': 18, 'marks': 95, 'school': 'School2' },
               { 'name': 'C', 'age': 19, 'marks': 97, 'school': 'School2' }]
  
  db.posts.insert( new_posts )
  </code></pre>
  
  <p>We create indexes as follows..</p>
  
  <pre><code>db.posts.create_index([('name',1),('school',1)],unique=True)
  </code></pre>
  
  <p>Now we perform two operations..</p>
  
  <pre><code>db.posts.update({ 'name':'A', 'age': 17, 'school': 'School3' },
                  { 'name':'D', 'age':  17, 'marks': 70, 'school': 'School1' },
                     upsert=True )
  
  db.posts.update({ 'name':'A', 'age': 17, 'school': 'School1' },  
                  { 'name':'A', 'age': 17, 'marks': 60, 'school': 'School1' },
                     upsert=True )
  </code></pre>
  
  <p>What does the update() returns here? How can we find out weather the document is inserted into the db or existing document is updated?</p>
  
  <p>Can we do something like..</p>
  
  <pre><code>post1 = db.posts.update({ 'name':'A', 'age': 17, 'school': 'School3' },
                          { 'name':'D', 'age':  17, 'marks': 70, 'school': 'School1' },
                          upsert=True )
  
  post2 = db.posts.update({ 'name':'A', 'age': 17, 'school': 'School1' },
                          { 'name':'A', 'age': 17, 'marks': 60, 'school': 'School1' },
                             upsert=True )
  
  print post1
  
  print post2
  </code></pre>