Database
Last updated
Last updated
If you haven't already create a firebase project: .
Add Firestore database, to your project in Firebase
In Firebase side panel, navigate to: Project Overview -> Project Settings -> Service Accounts -> Generate new private key
to generate service account json file, which contains private key. You can also visit this URL: https://console.firebase.google.com/u/0/project/{project-id}/settings/serviceaccounts/adminsdk
but replace the {project-id}
with your project.
Set following .env
variables:
AUTH_FIREBASE_PROJECT_ID
- id of your firebase project
AUTH_FIREBASE_CLIENT_EMAIL
- service account email (get it from step 3 json file)
AUTH_FIREBASE_PRIVATE_KEY
- private key (get it from step 3 json file)
Now your Firestore is setup :)
Now we need to create an extra user which will be only used by our app. It needs to have read/write access. In side panel, go to Security -> Database Access -> Add new Database user
Now we need to get "connection string" URI. In side panel, go to Deployment -> Database -> Connect
. After modal opens, select Drivers
and at the bottom you will see connection string looking like mongodb+srv://<db_username>:<db_password>@...
Set following .env
variables:
MONGO_DB_URI
- connection string from step 3
Note: Make sure that after first /
in connection string, you write the DB name which you want to use (otherwise by default it's test
). Example of connection string: mongodb+srv://{username}:{password}.../dbName
Now your MongoDB is setup :)
Database adapter is controlled through the appConfig.ts
file.
Each adapter has it's own set of required environment variables, together with it's own implementation of common functions to interact with the database.
Adapters don't implement actual business logic. Business logic is handled in the database/index.ts
file together with "collection names".
Collection names are names of tables/collections in the database.
Create MongoDB account and cluster if you haven't already: