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

[FEATURE] multiple firestore #196

Open
stefdelec opened this issue Oct 15, 2020 · 2 comments
Open

[FEATURE] multiple firestore #196

stefdelec opened this issue Oct 15, 2020 · 2 comments
Labels
feature-request Feature Request

Comments

@stefdelec
Copy link

Hi

Thanks for this great lib. We have an express app using multiple firestore projects. Do you think it is feasible to make evolve your lib in order to handle multiple firestore project?

I can do it but I have looked at the code, and I don't really know the best way to do it.

Stéphane.

@wovalle wovalle assigned wovalle and unassigned wovalle Oct 15, 2020
@wovalle wovalle added the enhancement New feature or request label Oct 15, 2020
@wovalle
Copy link
Owner

wovalle commented Oct 15, 2020

Thanks for the suggestion!

Can I ask what would be the use case of having two stores in the same project?

To allow multiple stores we would need to re-think the way we register our metadata. For example, how would you assign Collections/CustomRepositories to a firestore store/instance in a type-safe way? 🤔

@wovalle wovalle added feature-request Feature Request and removed enhancement New feature or request labels Oct 15, 2020
@brunodmn
Copy link

brunodmn commented May 3, 2022

I'd like this feature too.
I am migrating my project to a new optimized database (old one is a mess), trying to read information from 'project-old' and write on 'project-new'. Eventually I'll discontinue 'old-project'.

"Why don't you just copy the data from one project to another?"
A: Its a really large database with lots of data of inactive clients I do not need to import. I'd rather "lazy import" as user login to my new system.

Maybe we could have a optional parameter on decorations to reference the projectId assigned on module initialization.
ie.

[...]
imports:[
FireormModule.forRoot({
      firestoreSettings: {
        projectId: 'project-old',
        credential: cert(require('path-to-config')),
      },
      fireormSettings: {validateModels: true},
    }),
FireormModule.forRoot({
      firestoreSettings: {
        projectId: 'project-new',
        credential: credential.applicationDefault(),
      },
      fireormSettings: {validateModels: true},
    }),
]
[...]

on entity

@Collection(entityName: 'bands', projectId: 'project-new')
export class Band {
[...]
}

@Collection(entityName: 'bands', projectId: 'project-old')
export class BandOld extends Band {
constructor(){
        super();
    }
[...]
}

on injections

[...]
@Injectable()
export class BandService {
  constructor(
@InjectRepository(Band) private newBand:  BaseFirestoreRepository<Band>,
@InjectRepository(BandOld) private oldBand:  BaseFirestoreRepository<BandOld>,
){}
[...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Feature Request
Projects
None yet
Development

No branches or pull requests

3 participants