title: Mongoose Query update, $pull, multi
body: <p>A short and simple question.</p>
  
  <p>Would someone be kind enough to tell me what the Mongoose equivalent of this Mongo query would be...</p>
  
  <pre><code>db.users.update({ groups: "d" },{ $pull: { groups: "d" } },{ multi: true })
  </code></pre>
  
  <p>Just getting my head around more basic mongoose queries but struggling with some of the more complex stuff. Think this will help me see lots of the basic principles.</p>
  
  <p>Thanks!!!</p>
  
  <p>Schema as requested (relevant part only)...</p>
  
  <pre><code>var UserSchema   = new Schema({
      //....other fields  
      group: [Schema.Types.ObjectId],
      //....other fields
  });
  
  ....
  
  module.exports = mongoose.model('User', UserSchema);
  </code></pre>
  
  <p>The 'd' in my question was just an example, it would actually be a 'group id' in my app.</p>
  
  <p><strong>Solution thanks to chridam...</strong></p>
  
  <pre><code>var conditions = { group: groupId };
  var update = { $pull: { group: groupId }};
  var options = { multi: true };
  
  User.update(conditions, update, options, callback);
  function callback (err, numAffected) {
      // Do things here
  }
  </code></pre>