Mongoose pushing in an array in a nested subdocument
<p>I have this schema: </p>

<pre><code>var UserSchema = new Schema({
  profile: {
    firstName: {type: String, trim: true, required: true },
    lastName: {type: String, trim: true, required: true },
    city: {type: String}
    age: {type: Number, min: 13, max: 120},
    image: {type: String,trim: true}
  },
  friends:{
    accepted:[{
       id: {type: mongoose.Schema.Types.ObjectId, ref: 'User'},
       dateAccepted: {type: Date, default: Date.now}
    }]
  }
}
</code></pre>

<p>How can I push data in friends.accepted with .update method ?</p>

<p>I succeed only with the findOne method:</p>

<pre><code>User.findOne({
  _id: id
  },function(err,user){
    user.friends.accepted.push(newUser._id);
    user.save(function(err){if(err) return err;})
  });
</code></pre>