🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@fluojs/drizzle

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fluojs/drizzle

Drizzle ORM integration for Fluo with ALS transaction context, async module factory, and optional dispose hook.

Source
npmnpm
Version
1.0.0-beta.1
Version published
Weekly downloads
40
66.67%
Maintainers
1
Weekly downloads
 
Created
Source

@fluojs/drizzle

English 한국어

Drizzle ORM integration for fluo with a transaction-aware database wrapper and an optional dispose hook.

Table of Contents

Installation

npm install @fluojs/drizzle

When to Use

  • when Drizzle should participate in the same module, DI, and lifecycle model as the rest of the app
  • when repositories need a single current() seam that switches between the root handle and the active transaction handle
  • when application shutdown should also run an explicit cleanup hook for the underlying driver resources

Quick Start

import { ConfigService } from '@fluojs/config';
import { Module } from '@fluojs/core';
import { DrizzleModule } from '@fluojs/drizzle';
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';

@Module({
  imports: [
    DrizzleModule.forRootAsync({
      inject: [ConfigService],
      useFactory: async (config: ConfigService) => {
        const pool = new Pool({
          connectionString: config.getOrThrow<string>('DATABASE_URL'),
        });

        return {
          database: drizzle(pool),
          dispose: async () => {
            await pool.end();
          },
        };
      },
    }),
  ],
})
export class AppModule {}

Common Patterns

Use DrizzleDatabase.current() inside repositories

import { DrizzleDatabase } from '@fluojs/drizzle';
import { eq } from 'drizzle-orm';
import { users } from './schema';

export class UserRepository {
  constructor(private readonly db: DrizzleDatabase) {}

  async findById(id: string) {
    return this.db.current().select().from(users).where(eq(users.id, id));
  }
}

Manual transaction boundaries

await this.db.transaction(async () => {
  const tx = this.db.current();
  await tx.insert(users).values(user);
  await tx.insert(profiles).values(profile);
});

Request-scoped transactions with an interceptor

import { UseInterceptors } from '@fluojs/http';
import { DrizzleTransactionInterceptor } from '@fluojs/drizzle';

@UseInterceptors(DrizzleTransactionInterceptor)
class UsersController {}

Manual Module Composition

Use DrizzleModule.forRoot(...) / forRootAsync(...) to register Drizzle. When you need to compose Drizzle support inside a custom defineModule(...) registration, import the module entrypoint there as well.

import { defineModule } from '@fluojs/runtime';
import { DrizzleDatabase, DrizzleModule, DrizzleTransactionInterceptor } from '@fluojs/drizzle';

const database = {
  transaction: async <T>(callback: (tx: typeof database) => Promise<T>) => callback(database),
};

class ManualDrizzleModule {}

defineModule(ManualDrizzleModule, {
  exports: [DrizzleDatabase, DrizzleTransactionInterceptor],
  imports: [DrizzleModule.forRoot({ database })],
});

Public API Overview

  • DrizzleModule.forRoot(options) / DrizzleModule.forRootAsync(options)
  • DrizzleDatabase
  • DrizzleTransactionInterceptor
  • DRIZZLE_DATABASE, DRIZZLE_DISPOSE, DRIZZLE_OPTIONS
  • createDrizzlePlatformStatusSnapshot(...)

DrizzleModule

  • DrizzleModule.forRoot(options) / DrizzleModule.forRootAsync(options)
  • forRootAsync(...) accepts AsyncModuleOptions<DrizzleModuleOptions<...>>.
  • Supports strictTransactions: true to throw if transaction support is missing.
  • @fluojs/runtime: owns module startup and shutdown sequencing
  • @fluojs/http: provides the interceptor pipeline used for request transactions
  • @fluojs/prisma and @fluojs/mongoose: alternate ORM/ODM integrations with the same fluo runtime model

Example Sources

  • packages/drizzle/src/vertical-slice.test.ts
  • packages/drizzle/src/module.test.ts
  • packages/drizzle/src/public-api.test.ts

Keywords

fluo

FAQs

Package last updated on 24 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts