Actually I am using mongodb with Express js framework and check the email exists with my custom code and now I want to check the email is existed in my collection or not with the package that can easy to use with the Express js framework.
If_exists(req,res,callback) {
var mongoose = require('mongoose');
var Auth = mongoose.model('Auth');
Auth.findOne({email:req.body.email}, function (err1, user1) {
if (user1) {
var error = "email";
var message = "Email already exists";
callback(error,message);
return;
}
else {
var error = "";
var message = "";
callback(error,message);
return;
}
});
}