I am saving data to firebase. However, I want to save it to the logged in user node, at the moment the data is being saved to its own node. I have some code what I have been recommened which I thought would work.
this.diary = db.list(‘UID’);//this is where I think I am going wrong?
let user = firebase.auth().currentUser;
handler: data=> {
this.diary.child(user.uid).set({
country: data.a,
city: data.b,
month: data.c,
day: data.d,
time: data.e
})
with the code above now I am getting the error ‘child does not exist on type firebaselistobservable’ ??
Any help would be great thanks.
You can’t use .child()
on an AngularFireList
.
.child()
is a part of the JS SDK.
You’d want to do something like:
const user = firebase.auth().currentUser;
this.diary = db.object(`UID/${user.uid}/`);
handler: data => {
this.diary.set({
// All the stuff you had inside
})
}
I have created it using your tutorial for the event list.
One an event has been created can a user edit or delete that?
My tutorial doesn’t use AngularFireList
, it uses the regular JS SDK, so you’re creating a .child()
on a .ref()
.
Yes, you need to program it to do that, I just show you how to create it because we cover the update part on the user profile section