Reputation: 538
This is an example order document I have
{numberOfHours: 10, status: “BOOKED”, hidden: true},
{numberOfHours: 5, status: “NOT_BOOKED”,hidden: true},
{numberOfHours: 1, status: “BOOKED”, hidden: true},
{numberOfHours: 10, status: “PENDING”, hidden: true}
This is my requirement. I want to find all which are not hidden(hidden = false)
. But if the status is “BOOKED”
it should show even if hidden
is true
. I will have to use a collection.find()
as well
This is my query -
{ $expr: {
$eq:[ {
$cond: {
if: { "$status" : { $ne: "BOOKED"} },
then: {"$hidden"},
else: {null}
}
},
false ] }
}
How to proceed from here? Any help will be highly appreciated.
Upvotes: 3
Views: 1853
Reputation: 4453
{$expr: {
{$cond: {
"if": {"$eq": ["$status", "BOOKED"]},
"then": {"$hidden"},
"else": {null}
}
},false}
}
Note:- I have given an answer based on your question. Hope this will help you.
Upvotes: 2