推出我自己独特的电子邮件检查方法。使用 .equalTo 和 .find 即使数据库中没有任何内容,我仍然可以成功。如果找不到匹配项,我需要它出错。有任何想法吗?
// 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!");
}
}
});