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

ref.push() not resolving if ref.set() used separately #123

Open
Redmega opened this issue Dec 10, 2018 · 0 comments
Open

ref.push() not resolving if ref.set() used separately #123

Redmega opened this issue Dec 10, 2018 · 0 comments

Comments

@Redmega
Copy link

Redmega commented Dec 10, 2018

I have the following function written with .push() followed by .set() separately because I need to duplicate my id into the document for legacy reasons.

async createItemInCategory(category, data) {
  const ref = await this.db.ref(`categories/${category}`).push()

  const item = {
    ...data,
    id: ref.key,
    created: Date.now(),
    updated: Date.now()
  }

  await ref.set(item)

  return item
}

When testing this function, it never resolves, causing jest to timeout.

I haven't had the chance to test it if used in tandem, to see if .push().set() works, but in this particular case I would need to make two firebase calls to accommodate having id in the document, when the code, unchanged, works as expected with an actual firebase instance.

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

1 participant