It's a bit hard to do this with angularFireCollection
without iterating over all the entries to check for duplicates. It might be easier to use angularFire
and use the name as the unique key:
function MyController($scope, angularFire) {
var url = "https://<my-firebase>.firebaseio.com/ClientList";
var promise = angularFire(url, $scope, "users", {});
promise.then(function() {
$scope.addUser = function(user) {
if ($scope.users[user.name]) {
throw new Error("User already exists!");
} else {
$scope.users[name] = user;
}
}
});
}
Hope this helps!