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")
]
}
}
}
}
}
}
])