Overview
The Resolid Framework provides database integration through Drizzle ORM with support for multiple database providers. This guide covers setting up database connections and using the database service.Installation
Install the database package for your preferred database:Creating a Database Extension
Use the appropriate function to create a database extension for your application:MySQL
Configuration
Single Connection
Configure a single database connection:Multiple Connections
Configure multiple named database connections:Using the Database Service
Inject theDatabaseService to access database connections:
Accessing Named Connections
Defining Database Schema
Use thecreateDefineTable helper to create table definitions with a prefix:
Repository Pattern
Extend theRepository base class for organized data access:
Database Migrations
Use Drizzle Kit for database migrations:- Install Drizzle Kit:
- Create a
drizzle.config.ts:
- Generate and run migrations:
Connection Pooling
The database service uses connection pooling by default. You can customize pool settings:Connection Enhancer
Use theenhancer option to customize the connection pool:
Cleanup
The database service automatically closes connections when the application is disposed:Complete Example
Source Code
Location:packages/app-db-mysql/src/index.ts