How to only get the array nested subdocuments with that document id and not having to iterate through it

there are many and more

db.collection.aggregate([
  {
    "$match": {
      "_id": ObjectId("605a3a82c8bbb404f4e6b643")
    }
  },
  {
    "$unwind": "$address"
  },
  {
    "$match": {
      "address._id": ObjectId("605a3b3bc8bbb404f4e6b645")
    }
  },
  {
    "$replaceRoot": {
      "newRoot": "$address"
    }
  }
])

this also works

db.collection.aggregate([
  {
    "$match": {
      "_id": ObjectId("605a3a82c8bbb404f4e6b643")
    }
  },
  {
    "$replaceRoot": {
      "newRoot": {
        "$first": {
          "$filter": {
            "input": "$address",
            "as": "item",
            "cond": {
              $eq: [
                "$$item._id",
                ObjectId("605a3b3bc8bbb404f4e6b645")
              ]
            }
          }
        }
      }
    }
  }
])
2 Likes