I'm trying to use AngularFire for my Google Firebase Ionic app. I'm particularly facing issues with the design of my database and the implementation afterwards.
My goal is to have users, with some basic info like name and e-mail.
Every user should be able to add friends. These friends are stored in a list. What is the best way to go about this in the Firebase Database? Should users have a friendlist node pointing to other user id's?
var friendsRef = firebase.database().ref('users/' + firebase.auth().currentUser.uid + '/friends');
$scope.friends = $firebaseArray(friendsRef);
I would go with the first option. But with flattening the data.
users user1 name email user2 user3 friendlist user1 user2 user5 user11 user2 user3
that way you won't retrieve the whole data (with friendlist) when querying for a users data.
update() method to save data in multiple location at once. If someone wants to delete a friend a user, you can
update() to remove both user from each other's list.
Use security rules to control who can see who's data. For example a
user1's data will be visible to
user1 or those who have their