Skip to content

Multiple Databases Exception #306

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
ndevr opened this issue Jun 30, 2016 · 2 comments
Closed

Multiple Databases Exception #306

ndevr opened this issue Jun 30, 2016 · 2 comments

Comments

@ndevr
Copy link

ndevr commented Jun 30, 2016

Got a error if working with multiple databases.

// relative URL, uses the database url provided in bootstrap
const relative = af.database.object('/item');
// absolute URL
const absolute = af.database.object('https://another-db.firebaseio.com/item');

EXCEPTION: Error: FIREBASE FATAL ERROR: database.refFromURL: Host name does not match the current database: (found another-db.firebaseio.com but expected db.firebaseio.com)

Creating a new instance of Firebase is not possible. Ends up in a

Error: Unresolved Type Firebase

@davideast
Copy link
Collaborator

We do not support absolute urls for multiple database. The absolute url only works for the configured database in the bootstrap phase.

You can initialize a new Firebase App and then create a reference from that and pass it into a list or object.

const config = { }; // config here
const app = firebase.initializeApp(config);
const ref = firebase.database.ref().child('item');
af.database.object(ref);

@Shane-Lester
Copy link

Is there any way to programatically alter which database gets bootstrapped? Or do you just have to set up the hardcoded primary DB and then set up a secondary one?

If using the above approach - how do you authenticate with the second DB? I don't understand how you AngularFire (injected as af) knows which DB to authenticate as.

Thanks

Shane

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

4 participants