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

[FR] How to use RealtimeDatabase emulator in sdk admin? #631

Closed
jhorlima opened this issue Aug 24, 2019 · 5 comments
Closed

[FR] How to use RealtimeDatabase emulator in sdk admin? #631

jhorlima opened this issue Aug 24, 2019 · 5 comments

Comments

@jhorlima
Copy link

I would like to use the realtimedatabase emulator to test some hooks I am creating without having to submit to production.

@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@ryanpbrewster
Copy link
Contributor

ryanpbrewster commented Aug 28, 2019

This works for me (assuming the Realtime Database emulator is running at localhost:9000):

const admin = require("firebase-admin");
async function main() {
  admin.initializeApp({ databaseURL: "http://localhost:9000?ns=foo" });

  await admin.database().ref().set(42);

  const root = await admin.database().ref().once("value");
  console.log(root.val());
}

main().catch(err => console.error(err)).then(() => {
  console.log("ok!");
  admin.apps.forEach(app => app.delete());
});

@hiranya911
Copy link
Contributor

@ryanpbrewster is there any docs page we can point developers to? If not shall we work on putting together one?

@ryanpbrewster
Copy link
Contributor

We're actively working on expanding this guide: https://firebase.google.com/docs/emulator-suite

I do not believe it currently has any information on how to connect with the Node.js SDK, but it will shortly.

@hiranya911
Copy link
Contributor

Sounds good. Thanks @ryanpbrewster.

I'll close this issue since there's no action item for this repo.

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

No branches or pull requests

5 participants