Skip to content
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

Firebase.database().push does not return key #522

Closed
maitham opened this issue Oct 16, 2017 · 3 comments
Closed

Firebase.database().push does not return key #522

maitham opened this issue Oct 16, 2017 · 3 comments
Labels
plugin: database Firebase Realtime Database

Comments

@maitham
Copy link

maitham commented Oct 16, 2017

Issue

I'm currently using redux saga and react native firebase however after pushing an object nothing is returned in v2.2 it would return a result where I could get a query back however it seems its broken in this case unless im doing something wrong?
const result = yield call([dbRef, dbRef.push], () => eventObj);

Environment

  1. Application Target Platform:
    Both
  1. Development Operating System:
    macos
  1. Build Tools:
    xcode
  1. React Native version:
    0.49.3
  1. RNFirebase Version:
    v3.0.3
  1. Firebase Module:
    database
@Ehesp
Copy link
Member

Ehesp commented Oct 17, 2017

Hello, not sure how saga works but are you expecting it to return a promise here?

@chrisbianca
Copy link
Contributor

@MaithaM1 There was a change in v3 to push to bring it in line with the Web SDK. Details are in this issue: #147

@Salakar can provide some more information as he made the change.

@chrisbianca chrisbianca added the plugin: database Firebase Realtime Database label Oct 17, 2017
@Salakar
Copy link
Member

Salakar commented Oct 17, 2017

@MaithaM1 push promise no longer resolves with the reference, you need to change your code to something like the following:

const thenableRef = dbRef.push();

// new ref is an instance of DatabaseReference with .then() support, just like the web sdk
console.log(newRef.key)
console.log(newRef.path)

// set the value if needed
const pushResult = await thenableRef.set({ some: 'value' });

See the official web sdk reference guide: https://firebase.google.com/docs/reference/js/firebase.database.ThenableReference#push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: database Firebase Realtime Database
Projects
None yet
Development

No branches or pull requests

4 participants