title: Mongoose: Overwriting array property on update
body: <p>How can I overwrite an array property of a document based on a given array as the source?</p>
  
  <p>Schema:</p>
  
  <pre><code>var postSchema = new mongoose.Schema({
      title: { type: String, required: true, index: { unique: true } },
      content: { type: String },
      tags: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Tag' }]
  });
  </code></pre>
  
  <p>I now have an array with ids of tag objects and I would like to overwrite the tags property. The problem I'm having now is that it adds new tags but it does not remove tags that are not in the source array.</p>
  
  <p>I'm currently performing the update using findOneAndUpdate as follows:</p>
  
  <pre><code>// Pseudo code example
  Post.findOneAndUpdate({ _id: id }, { tags: ["id1...", "id2..."], {}, cb);
  </code></pre>