[
{
$project: {
_id: 1,
followUps: 1,
duplicateNames: {
$filter: {
input: {
$map: {
input: "$followUps",
as: "f",
in: "$$f.name"
}
},
as: "name",
cond: {
$and: [
{ $ne: ["$$name", "Check_in"] },
{
$gt: [
{ $size: {
$filter: {
input: {
$filter: {
input: "$followUps",
as: "innerF",
cond: { $eq: ["$$innerF.name", "$$name"] }
}
},
as: "duplicate",
cond: { $eq: ["$$duplicate.name", "$$name"] }
}
}
},
1
]
}
]
}
}
}
}
},
{
$match: {
$expr: { $gt: [{ $size: "$duplicateNames" }, 0] }
}
},
{
$project: {
_id: 1
}
}
]
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter