I have a collection:
{
"_id": 1,
"_deleted": false,
"customFields": [{
"fieldName": "sapID",
"value": ""
}, {
"fieldName": "salesTerritory",
"value": ""
}, {
"fieldName": "clientType",
"value": "Corporate"
}],
}
How can I project(aggregate)
only the value
field of the element with fieldName = "clientType"
:
db.collection.aggregate(
{
$project:{value:<code>}
}
)
I tried $filter
but it does not work
2
Answers
mongoplayground
mongoplayground
What about this?
Mongo Playground