You can use aggregation to filter out objects from array.
db.collection.aggregate([
{
"$addFields": {
"newsSources": {
$filter: {
input: "$newsSources",
cond: {
$in: [
"D0108",
"$$this.clientId"
]
}
}
}
}
}
])
Working Mongo playground
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…