here is my mongoose query(and the router):
router.get('/reportsRegular', function(req,res,next){
Question.find({reports: {$size: {$gt: 0}}, checked: false}).sort({reports: -1}).limit(20).exec(function(err,results){
console.log(results)
res.render('reports', {type: 'regular', user: req.user, reports: results})
})
and it seems there is a problem with the first find condition, when I remove the $gt to 1 instead it works, but it wont work in cases with more then one, so I need to use $gt.
here is an example JSON document that should work but does not get found:
{
_id: new ObjectId("6212e77aa1e98ae3282a61e6"),
title: 'TOMATOOOOOO',
text: '<p>AAAAAAAAAAAAAAAA</p>',
authorUsername: 'SweetWhite',
dateCreated: 2022-02-21T01:14:34.901Z,
answers: [],
likes: [ 0 ],
dislikes: [ 0 ],
tag: 'Languages',
views: [ 1, 'SweetWhite' ],
reports: [ 'SweetWhite' ],
checked: false,
reportsNested: [],
__v: 0
}
it should get found since the size of the reports array is bigger then zero, and the checked value is false.
What am I doing wrong?
Thanks!