Using find() with Mongoose

why isnt the ‘find’ working properly & filter based on dates is returning all the data in the DB

      Users1.find({
                _id:userId,
                'log.date' :{
                  $lte: to != 'Invalid Date' ? to.getTime() : Date.now(),
                  $gte: from != 'Invalid Date' ? from.getTime() : 0
                }
              }

Also why is the below not working? why is the date still returning null & not Date.now()
const date = req.body.date != null ? req.body.date : Date.now() ;

Thanks for the help :slight_smile:

you can find the complete code on