Here I am using mongoose for my Mean application which consists of nodejs, expressjs and angularjs.
My problem here is I need to use different find conditions and according send the error message or data
Now I am using as below
User.findOne({ Email: req.body.Email }, (err, user) => {
if (err) { return done(err); }
if (!user) {
return res.json("Account with that email address does not exist.");
}
mongoose schema
const userSchema = new mongoose.Schema({
FirstName: String,
LastName: String,
Email: { type: String, unique: true },
UserName: String,
Password: String,
PhoneNumber: String,
EmailVerified : Boolean,
AdminApproved : Boolean
}, { versionKey: false });
but now I had fields like email verified and adminapproved.
In Ms-Sql i used case statement like
- where (Email not present) then
show Email not exist - where (Email present and not email verified ) then
show please verify email - where (Email present, Email verified and not adminapproved) then
show wait for admin process
Can anyone help me in mongoDB using mongoose how to achieve the same operation.
via charan tej
No comments:
Post a Comment