samedi 11 août 2018

How to use conditional if and else with mongoose Schema?

I want to execute the following block of code if minimumquerytime equal to some definite value else call another function

  WeatherSchema.find({
      'location':city,
      'time':{
       $gt:minimumquerytime
       })
       .sort({'time':'desc'})
       .limit(1).
       then(datas=> res.json(datas))
          });

like this

if(foundindatabase){
showthatvalue
}
else{
callanotherfunction
}

But unable to connect. How can I accomplish this?

Aucun commentaire:

Enregistrer un commentaire