JSFiddle - React, Tailwind, and code Playground
by Dean Kamali
JavaScript
treatment = {
progressNotes: [
{
visit: "1",
status: "preposed",
},
{
visit: "1",
status: "preposed",
},
{
visit: "2",
status: "completed",
}
]
}
mm.aggregate(treatment.progressNotes, [
// Stage 1
{
$unwind: {
path: "$treatment.progressNotes",
includeArrayIndex: "arrayIndex", // optional
preserveNullAndEmptyArrays: false // optional
}
},
// Stage 2
{
$match: {
"treatment.progressNotes.status": "completed"
}
},
])