Remove embedded document in a nested array of documents

You are so close! Remember that your outermost “content” is an array itself. So the following 2 character change works, use content.$.assets inside the value for $pull.

db.presentations.update(
  {'content.assets._id': ObjectId('4fc63def5b20fb722900010e')}, 
  {$pull: {'content.$.assets': {'_id': ObjectId('4fc63def5b20fb722900010e')}}}
)

Zoom ahead.

Leave a Comment