Can not have access to multiple Google Firestore DB in Angular 6 application with angularfire2

Farhad

I try to have access to multiple Google Firestore DB from my Angular 6 application through angularfire2 package.

I initialized multiple instance of AngularFireModule in app.module.ts but couldn't find a way to have access to both DBs:

  @NgModule({
  declarations: [
	...
  ],
  imports: [
	...
    AngularFireModule.initializeApp(coolStoreConfig, 'coolStore'),
    AngularFireModule.initializeApp(perfectStoreConfig, 'perfectStore'),
	...
  ],
  ...
 })

Any idea?

Farhad

After some searches around, the following answer could help a lot: angular2firebase - multiple instances using Angular 6

looks like creating providers for each instance can be a good idea

...
{ provide: AngularfirestoreCoolStoreService, deps: [PLATFORM_ID, NgZone], useFactory: AngularfirestoreCoolStoreFactory },
{ provide: AngularfirestorePerfectStoreService, deps: [PLATFORM_ID, NgZone], useFactory: AngularfirestorePerfectStoreFactory }
...

I created a stalkblitz which shows how it works: https://stackblitz.com/edit/angular-or2ehb

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

access another firestore data in angularfire2

Firebase - Firestore - Angularfire2 - Angular : How do I access key values within the controller?

Angular 6 and AngularFire2 RxJS Error

How to bind multiple query results in angularfire2 with firestore?

Angularfire2 Firestore Update same field in multiple documents

How to implement SSR with Angular 6 and AngularFire2

reverse an observable array in angularfire2 angular 6

angularfire2 - how can use multiple where clauses in firebase?

In Angular (using angularfire2 and typescript) how do you get types on errors thrown when using firestore?

Angular Firestore (angularfire2) - Pull all "comments" that match a "photo" id

How can I translate text input in AngularFire2 Firestore use ngx-translate?

Angular 4 with AngularFire2

can't have access to dom element in angular2

Any pointers on using AngularFire2 With GAPI to Access Google Analytics Reporting

Read and update below formatted data of Fire-base in Angular 5 application using AngularFire2

How can I sort a FirebaseListObservable list in Angularfire2 Angular2?

Can we have multiple <router-outlet> angular2+?

Can we access two URL's for single Angular 2 application?

angularfire2: The Cloud Firestore API is not enabled

Need to unsubscribe Firestore/Angularfire2 subscription

*ngIf Firestore with Querying Collections / angularfire2

Angularfire2 + Firestore query result with reference

Issue in reading a firestore DB time stamp in an angular application and comparing

AngularFire2 DB call is not executed

Multiple Google access permissions for a desktop application

Angular 6 application cannot find namespace 'google'

AngularFire2 access data after retrieve it

Angularfire2 - Access object values

Angular2 and Firebase (AngularFire2)