- You can use
$mergeObjectsoperator to merge current object properties with updated property, - to prevent null value use
$ifNulland$$REMOVEoperator
[
{
$set: {
content: {
$map: {
input: "$content",
in: {
$mergeObjects: [
"$$this",
{
teaser: {
$map: {
input: "$$this.teaser",
in: {
$mergeObjects: [
"$$this",
{
uri: {
$ifNull: [
{
$replaceOne: {
input: "$$this.uri",
find: "mydomain.com",
replacement: "anotherdomain.com"
}
},
"$$REMOVE"
]
}
}
]
}
}
}
}
]
}
}
}
}
}
]