Database

Database

Implementation-accurate guide for Forge database extension

Overview

github.com/xraph/forge/extensions/database provides a unified extension for:

  • SQL databases via Bun (postgres, mysql, sqlite)
  • MongoDB
  • Redis (standalone, cluster, sentinel)

The extension registers a DatabaseManager and database accessors in the container, then coordinates connection lifecycle.

What This Extension Handles

  • Config loading from app config (extensions.database then database) plus programmatic options
  • Database object creation by DatabaseType
  • Eager registration/opening of configured databases through DatabaseManager
  • Default database selection
  • Typed helper access for SQL, Mongo, and Redis

Runtime Model

  • DatabaseManager is the central registry for named databases.
  • Database connections are opened with retry and backoff logic.
  • Health checks and metrics are emitted per database.
  • DatabaseManager implements service lifecycle methods (Start, Stop, Health).

Read This Next

How is this guide?

On this page