Q: mongoose validate check database Is it possible to have a validation in Mongoose that checks the database?
I need to have something like this
var validEmail = require('../helpers/validate/email');
var validDoctor = require('../helpers/validate/doctors');
var schema = mongoose.Schema({
  email: { type: string, validate: [validEmail, "invalid email"],
  doctor: {type: string, validate: [validDoctor, "invalid doctor"]
}

And validDoctor would look something like:
module.exports = function (doctor) {
  Doctors.findOne({email:doctor}, function (err, found) {
    return (found);
});

I have tried to put scripts in pre and post hooks, and my code is just getting too sloppy. I HAVE to have a validation like this

A: You need Async validation which accepts a second argument as a callback function to be called with either true or false denoting a successful or failed validation respectively
module.exports = function (doctor, done) {
  Doctors.findOne({email:doctor}, function (err, found) {
    if(found) done(true);
    else done(false);
});

