I would be grateful that you can help me with the following:
I have an Ionic 2 project, and need to know how to save objects with custom keys in Firebase database.
Actually, in Firebase I have:
+ blabla
+ blabla
- users :
- UIDXXX : {
+ last_audio: {}
+ sessions : []
}
Well, instead the string UIDXXX, I need to save the user's uid as key, for example:
- users :
- 232ssadas223ss2 : {
+ last_audio: {}
+ sessions : []
}
- das112dasd21dsd : {
+ last_audio: {}
+ sessions : []
}
.
.
.
This is how I'm retrieving data actually:
this.auth.subscribe((user) => {
if (user) {
let firebaseObservable = this.angularFire.database.object(`/users`);
firebaseObservable.update({
useruid : {
last_audio: this.audio,
sessions: [
"Hoy",
"Ayer"
]
}
});
}
});
But, obviously I'm saving the word "userid" as key instead the user.uid, and in Firebase I'm getting:
users :
- useruid : {
+ last_audio: {}
+ sessions : []
}
Thank you very much in advance.