Utilizing Firebase and AngularFire has opened up many different approaches for CRUD operations with the Firebase API. However, I am still uncertain about the specific differences between using:
- $add with $firebaseArray
- The .push() method
- The .set() method
Although these methods may seem technically equivalent, I find myself leaning towards using the .set() method without fully understanding why. Is there a particular reason why one should avoid using it? And what exactly does $firebaseArray do? Can we not simply declare a basic reference variable like in the following examples?
var usersRef = Ref.child('users');
$scope.createUser = function() {
$scope.userRef.child($id).set({
name: name
});
};
or
$scope.data = $firebaseArray(Ref.child('users'));
$scope.createUser = function() {
$scope.data.child($id).$add({
name: name
});
};
Thank you.