angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Get the key of item pushed onto a list

Open jongood01 opened this issue 10 years ago • 2 comments

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); } );

jongood01 avatar Jul 18 '16 21:07 jongood01

let key = af.database.list('myFirebasePath').push{key:val}).getKey();

OmerShemesh avatar Jul 21 '16 06:07 OmerShemesh

.push() does not return a Promise rather than a ThenableReference which contains the key value.

davideast avatar Jul 21 '16 12:07 davideast