Class: DrizzleService
Service that provides access to the Drizzle ORM instance.
Description
This service initializes and manages the Drizzle ORM connection to PostgreSQL. It wraps the connection pool with Drizzle ORM functionality and provides type-safe database operations through the schema definition.
Example
// Inject and use the service
class YourService {
constructor(private readonly drizzleService: DrizzleService) {}
async findUser(id: string) {
return await this.drizzleService.db.query.users.findFirst({
where: (users, { eq }) => eq(users.id, id)
});
}
}
Constructors
new DrizzleService()
new DrizzleService(
pool):DrizzleService
Creates a new DrizzleService instance.
Parameters
pool
Pool
The PostgreSQL connection pool
Returns
Properties
db
db:
NodePgDatabase<{users:any;expenses:any;inflows:any;userConsent:any;userActivity:any; }>
The Drizzle ORM database instance. Provides type-safe access to all database operations.