I have a list of tasks that I’m saving from Firebase using push() which generates an automated id
createTask(task: Task){
let uid = task.uid;
return firebase.database().ref().child(`/tasks/${uid}`).push(task)
.then(() =>{
/* add task to SQLite */
}, err =>{
console.log('rejected');
})
}
And here is where I retrieve those tasks, firedb
is an AgularFireDatabase
object.
return this.firedb.list(`/tasks/${this.uid}`).valueChanges();
I wanna get the list of tasks together with the associated key for each task, so that I can be able to pass that key or id to the function below
getTaskById(taskId){
return firebase.database().ref().child(`/tasks/${this.uid}/${taskId}`)
.once('value')
.then(snapshot =>{
console.log(snapshot.val());
})
}
Thanks