My problem was solved using this approah
db.collection('admin').findOne({"Email":req.body.Email},(err,result)=>{
try{ assert.equal(null,err);
assert.equal(req.body.Email,result.Email);
assert.equal(req.body.Password,result.Password);
console.log("found!!!!"+ result._id);
session.adminId=result._id;
res.redirect('/addstudent');
client.close();
}
catch(e){
session.studentId=null;
session.studentname = null;
session.registration=null;
session.Studentemail=null;
session.adminId=null;
console.log(e);
res.redirect('/admin');
}
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…