I have used mongoose and Node.js and I am facing this issue:
var dbvar;
doc_model
  .findOne({aadhar})
  .then(()=>{
    dbvar=1;
  });
paramedic_model
  .findOne({aadhar})
  .then(()=>{
    dbvar=2;
  });
console.log(dbvar);
There's 2 collection in my MongoDB and I want to change the variable dbvar accordingly. But when it reaches to console.log(dbvar), it shows me undefined.
 
     
     
     
    