fireorm
fireorm copied to clipboard
[FEATURE] multiple firestore
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.
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? 🤔
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>,
){}
[...]