Frontend Accelerator
Frontend Accelerator
  • Getting Started
    • Welcome
    • Start right now 👉
  • Setup
    • Database
    • Payments
    • Authentication
    • AI
  • Features
    • Dashboard
    • Localization
    • Changelog
    • Rich text editor
    • Lead magnet
    • Checkout button
    • Sign in button
    • Sales countdown banner
    • Capture email button
    • Locale switcher
    • Social icons
  • Extra
    • Theming
    • Support
Powered by GitBook
On this page
  • Firestore 🔥
  • MongoDB 🧩
  • Configuration
  1. Setup

Database

PreviousStart right now 👉NextPayments

Last updated 3 months ago

Supported providers:

Firestore 🔥

  1. If you haven't already create a firebase project: .

  2. Add Firestore database, to your project in Firebase

  3. 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.

  4. 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)

  5. Now your Firestore is setup :)

MongoDB 🧩

  1. 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

  2. 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>@...

  3. 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

  4. Now your MongoDB is setup :)

Configuration

Database adapter is controlled through the appConfig.tsfile.

database: {
  provider: DatabaseType.FIRESTORE // or DatabaseType.MONGODB
}

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.tsfile together with "collection names".

Collection names are names of tables/collections in the database.

Create MongoDB account and cluster if you haven't already:

https://account.mongodb.com/account/register
https://firebase.google.com/docs/firestore/quickstart
Firestore
MongoDB