check email or username exist or not in mongoose

 //check email / username exist or not

let userExist = await User.findOne({$or: [
{email: req.body.email},
{username: req.body.username}
]});
if (userExist) {
return res.status(400).json({
success: false,
message: ‘User already exist in same email’
});
}

Leave a Comment

Your email address will not be published. Required fields are marked *