Rolling out my own unique email checking method. Using .equalTo and .find I still get success even with nothing in the DB. I need it to error if there’s no match found. Any ideas?
// Check if email is already in use
var query = new Parse.Query(Email);
query.equalTo("email", email);
query.find({
success: function(results) {
self.$(".signup-form .error").html("Email already in use.").show();
this.$(".signup-form button").removeAttr("disabled");
},
error: function(error) {
if (error.code === Parse.Error.OBJECT_NOT_FOUND) {
alert("Perfect, could not find this email!");
Parse.User.signUp(username, password, { ACL: new Parse.ACL() }, {
// ... signUp method here ...
});
} else if (error.code === Parse.Error.CONNECTION_FAILED) {
alert("Uh oh, we couldn't even connect to the Parse servers!");
}
}
});
The find method will return successfully even when no objects are found which meet your criteria. You can check if results has any objects (it shouldn’t if the email hasn’t been taken), but what you’re probably looking for is the .first() method.