I have a status attribute and I want to apply a date filter only if status is pending, for the other status a date filter is not required.
- return only the status added to "$in".
- if status is pending apply a date filter (date is less than current time).
I do like this, but it is not working fine.
filter = { $and: [ {
'package' : {$in: ids},
'status': {$in: ['pending', 'accepted', 'charged', 'captured']},
date
},
{
$and:[
{status : 'pending', date:{$lt:current_time}},
]
}
]
};