title: mongo $push overwrites rather than adds to an array within a document
body: <p>I am trying to create a historical record for updates to a document in Mongo DB via NodeJS. The document updates are only in one object within the document, so it seems like creating an array of historical values makes sense.</p>
  
  <p>However, when I use the $push function with db.collection.update(), it only updates the array at the 0 index rather than add to the array.</p>
  
  <p>Here is what I have:</p>
  
  <pre><code>{
    _id: ID,
    odds: {
      spread: CURRENTSPREAD,
      total: CURRENTTOTAL,
      history: [
        0: {
          spread: PREVIOUSSPREAD1,
          total: PREVIOUSTOTAL1,
          date: DATEENTERED
        }
      ]
    }
  }
  </code></pre>
  
  <p>Here is what I would like:</p>
  
  <pre><code>{
    _id: ID,
    odds: {
      spread: CURRENTSPREAD,
      total: CURRENTTOTAL,
      history: [
        0: {
          spread: PREVIOUSSPREAD1,
          total: PREVIOUSTOTAL1,
          date: DATEENTERED1
        },
        1: {
          spread: PREVIOUSSPREAD2,
          total: PREVIOUSTOTAL2,
          date: DATEENTERED2
        },
        ...,
        n: {
          spread: PREVIOUSSPREAD-N,
          total: PREVIOUSTOTAL-N,
          date: DATEENTERED-N
        }
      ]
    }
  }
  </code></pre>
  
  <p>There is no need to check whether the previous value exists before adding.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>var oddsHistoryUpdate = { 
    $push: { 
      'odds.history': { 
        spread: game.odds.spread, 
        total: game.odds.total, 
        date: Date.now() 
      } 
    } 
  }
  db.collection('games').update({"_id": ID}, oddsHistoryUpdate).
  .then(finish executing)
  </code></pre>
  
  <p>Why is it only pushing to the 0 index instead of adding to the array? How do I fix?</p>