Hello guys I am trying to check if a user already exists in the database, I have managed to stop creating a user if one already exists with the same phone number , however I do not seem to get the error message displayed. I am not too sure why my error is not being handled correctly. Here is my code:
exports.usercreate = function(req, res){
users.create(req.body,function(err,done){
query = N1qlQuery.fromString("select * from `bucketname` where phonenumber=" +req.body.phonenumber +" and _type='users'")
console.log(query);
if(req.body.phonenumber==query){
res.status(500).json({status:"error", resCode: 500, msg:"users Already exist"});
}
else{
res.status(200).json({status:"success", resCode: 200, msg:"users Added Successfully"});
}
});
};