title: Mongoose unshift findAndUpdateById
body: <p>What's, if there is, the correct way to <em><code>unshift</code></em> a value into a Mongoose document's array through <code>findByIdAndUpdate</code>?</p>
  
  <p>I tried this which doesn't give error but also doesn't seem to update the value</p>
  
  <pre><code>Schema.findById(id, function(err, doc){
      console.log(doc.array.length); // =&gt; 1
      Schema.findByIdAndUpdate(id, 
          { array: { unshift: { property: 'value' } } }, 
          { upsert: true },
          function(err, doc) { 
              console.log(doc.array.length); // Also =&gt; 1
          }
      );
  });
  </code></pre>
  
  <p><code>$push</code> works. <code>$unshift</code> gives the error</p>
  
  <blockquote>
  <pre><code>[MongoError: exception: Unknown modifier: $unshift
  </code></pre>
  </blockquote>
  
  <p><a href="http://mongoosejs.com/docs/migration.html#arrays" rel="nofollow">Docs say to use <code>unshift</code> instead</a>, but it doesn't work. Or am I using it wrong? It doesn't give any error, just doesn't update the array..</p>