Skip to content

Get the key of item pushed onto a list #366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jongood01 opened this issue Jul 18, 2016 · 2 comments
Closed

Get the key of item pushed onto a list #366

jongood01 opened this issue Jul 18, 2016 · 2 comments

Comments

@jongood01
Copy link

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

@OmerShemesh
Copy link

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

@davideast
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants