I have a situation where i need to get the dates between specific dates and also get the dates which are not thr (meaning which are empty)
Below is the way of query that am presuming to work like, please help me get corrected.
EvaluationTraining.find({
mnguser: userid,
evalDate: "", //i want the empty ones too
evalDate: {
'$gte': firstDay,
'$lte': lastDay
}
})
.sort({evalDate: 'desc'})
.then(function(eval){
//results
})
.catch(function(err){
//err
})
Thanks in advance
try this
EvaluationTraining.find({
mnguser: userid,
$or: [{
evalDate: ""
}, {
evalDate:{
'$gte': firstDay,
'$lte': lastDay
}
}]
})
In case we need to find fields which is not present in a few documents instead of empty data, we can use $exists
EvaluationTraining.find({
mnguser: userid,
$or: [{
evalDate: { $exists: false }
}, {
evalDate:{
'$gte': firstDay,
'$lte': lastDay
}
}]
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With