Closed hchaucha closed 1 month ago
Hi @hchaucha 👋 Can you try downloading example project from here and modify it to suit your use case.
Hello, Thank you for the quick response. I created a dumb project based on provided example : https://github.com/hchaucha/nest-fireorm-test.
Obviously, I did modify the service account file and update all sensitive data with anonymized one.
The only difference with provided example is the Firestore initialization in the main.ts
(mentionned on Fireorm doc) :
I don't understand how it could works without it ?!
async function initializeFirestore() {
admin.initializeApp({
credential: admin.credential.cert(<admin.ServiceAccount>serviceAccount),
});
const firestore = admin.firestore();
firestore.settings({ timestampsInSnapshots: true });
fireorm.initialize(firestore);
}
Ok, understood !
But still, can't instantiate my database correctly : controller returns an empty array when .find()
function is fire.
Is the admin.initializeApp()
function required ? Is it possible to connect the database with project_id
only ?
You can provide you own firestore instance like this (a quick sketch, might require modifications):
FireormModule.forRootAsync({
useFactory: () => {
admin.initializeApp({
credential: admin.credential.cert(serviceAccount as admin.ServiceAccount),
});
const firestore = admin.firestore();
firestore.settings({ timestampsInSnapshots: true });
return { firestore };
},
),
Closing this as stale
Overview
Hi guys, I'm having some problems integrating Nest-fireorm and/or Fireorm. I'm not sure what I'm missing.
I followed these steps:
How to reproduce issue
Start by creating a new dumb project with all required dependencies :
Update
main.ts
file to initialize Firestore :Following Fireorm documentation (see : Fireorm usage)
At this point I'm able to initialize my Firestore instance and use it as follow :
Import Fireorm Module to
app.module.ts
:Following nest-fireorm documentation (see : nest-fireorm readme)
Define the User entity / collection / repository :
_Following Fireorm documentation (see : Fireorm Core-concepts)_
Here, I can't use
getRepository()
function as mentioned in Fireorm doc; thrown the following error :So I tried to skip this part since it's not mentionned on Nest-fireorm documentation.
Update
users.module.ts
to Inject User repository :Following Nest-fireorm documentation (see : nest-fireorm readme)
In documentation,
.forFeature()
function is called inapp.module.ts
which throw the following error :Finally, trying to consume User repository from
users.controller.ts
/users.service.ts
:In the best case, I have no crash but can't fetch my collection (results in null or empty array). Thank you for your help and your time !