How to run different stages, depending on the conditions of the result of a $match, to avoid requesting the database several times. First I find a user, if the user information is x I need to make another match, if it is y the match will be different:
const user = users.aggregate([
{ $match: { _id: _id } }
])
if (user.selectedPark) {
if (user.isAdmin) {
// indexed lookup
} else {
// indexed lookup
}
} else {
// indexed lookup
}