Hello,
What is the right way to do $sortArray
after $filter
?
I have tried doing the following:
$project: {
products: {
$filter: {
input: "$products",
cond: {
$eq: [
"$$product.requiresSignature",
true
]
},
as: "product"
},
$sortArray: {
input: "$products",
sortBy: {
recipient: 1.0
}
}
}
}
However, this will give the following error:
‘Invalid $project :: caused by :: FieldPath field names may not start with ‘$’. Consider using $getField or $setField.’
Could you kindly let me know how to correct the issue? Thank you