Error for checking user already exist in node js using couchbase

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"});
    }
   });
     };

I don’t know what’s in the request based on this code snippet, but it’s unlikely to match the N1QL response exactly. You’ll probably need to compare to a specific attribute in the results.

I’d probably set a breakpoint on this line in a debugger and see how query actually compares to the phone number.