I'm trying to create a todo list with Firebase. After a user authenticates with Google, the user can create tasks, but I can't figure out how to store the task to the user.
I'm trying to use .child(), but I can't know what the uid is for each user is. I also tried .orderByChild(), but that doesn't seem to do it , either (or I'm not using it right).
I've tried:
var firebase = new Firebase('https://<my-app>.firebaseio.com');
firebase.child('users').child(authData.uid).child('task').push({
status: 'In Progress',
taskName: $taskName.val(),
taskDescription: $taskDescription.val(),
taskCategory: $taskCategory.val()
})
authData.uid is given by Google on authentication:
firebase.authWithOAuthPopup('google', function(error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
// Stores user in Firebase
firebase.onAuth(function(authData) {
if (authData) {
firebase.child('users').child(authData.uid).set({
name: authData.google.displayName
});
}
});
}
});
firebase.child('users').child(authData.uid).child('task').push(...)would create a new node under users/$uid/task. Is it not what you want ?