Provides implicit and execution-scoped transactions/savepoints for drizzle-orm using Node.js async_hooks. Current stable version is 0.2.7. Release cadence is irregular; updates depend on community contributions. Key differentiator: avoids blocking transactions across functions/files/services, supports decorator-based AOP (@Transactional/@SavePoint), and includes a safe mode to catch common mistakes. Requires drizzle-orm ^0.44.7 and Node.js >=18. Works in Bun/Deno as well.
npm install drizzle-transaction-contextNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates setup of drizzle-transaction-context with Bun SQLite, creating a transaction context, and using useTransaction inside withTransaction to ensure both inserts are atomic.
Ensure you pass a drizzle instance created with schema: drizzle({ client, schema }).Upgrade to Node.js 24+ or use Bun/Deno for better performance.
Wrap calls to useTransaction() inside withTransaction() or a decorated method.
Pass a drizzle instance that includes the schema property.
Ensure useTransaction is called inside a callback passed to withTransaction, or inside a method decorated with @Transactional.
Create the drizzle instance with schema: drizzle({ client, schema }) before passing to createTransactionContext.