angularfire
angularfire copied to clipboard
Get the key of item pushed onto a list
There was a closed issue for this #199 but changes in the push method mean the answer no longer works. I am trying to do something like this but value is a promise and using preserveSnapshot on the list doesn't seem ideal:
const mylist = af.database.list('myFirebasePath'); const promise = mylist.push({key: val}).then((value) => { console.log(value.$key); } );
let key = af.database.list('myFirebasePath').push{key:val}).getKey();
.push() does not return a Promise rather than a ThenableReference which contains the key value.