npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@croco/tx-drizzle

v0.0.1

Published

Drizzle ORM용 `@croco/tx-core` 트랜잭션 어댑터입니다. Drizzle의 `db.transaction`/`tx.transaction(savepoint)`을 `tx-core`에 연결합니다.

Readme

@croco/tx-drizzle

Drizzle ORM용 @croco/tx-core 트랜잭션 어댑터입니다. Drizzle의 db.transaction/tx.transaction(savepoint)tx-core에 연결합니다.

설치

pnpm add @croco/tx-drizzle @croco/tx-core drizzle-orm typedi

사용법

1. Drizzle DB 생성 및 어댑터 연결

import "reflect-metadata";
import { Container } from "typedi";
import { TxManager } from "@croco/tx-core";
import { createDrizzleTxAdapter } from "@croco/tx-drizzle";
import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";

const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const db = drizzle(pool);

const adapter = createDrizzleTxAdapter(db);
const txManager = new TxManager(adapter, { defaultNesting: "join" });

Container.set(TxManager, txManager);

2. TxManager 등록

import 'reflect-metadata';
import { Container } from 'typedi';
import { TxManager } from '@croco/tx-core';
import { createDrizzleTxAdapter } from '@croco/tx-drizzle';
import { drizzle } from 'drizzle-orm/node-postgres';
import { Pool } from 'pg';

const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const db = drizzle(pool);

const adapter = createDrizzleTxAdapter(db);
const txManager = new TxManager(adapter, { defaultNesting: 'join' });

Container.set(TxManager, txManager);
      const adapter = createDrizzleTxAdapter(db);
      const txManager = new TxManager(adapter, { defaultNesting: 'join' });
      Container.set(TxManager, txManager);
    },
  ],
});

3. 서비스에서 @Transactional 사용

import { Service } from "typedi";
import { Transactional, TxManager } from "@croco/tx-core";

@Service()
class UserService {
  constructor(private readonly txManager: TxManager<typeof db>) {}

  @Transactional()
  async createUser(name: string) {
    const client = this.txManager.getClient()!;
    await client.insert(users).values({ name });
  }

  @Transactional({ nesting: "savepoint" })
  async updateUserWithSavepoint(id: string, name: string) {
    const client = this.txManager.getClient()!;
    await client.update(users).set({ name }).where(eq(users.id, id));
  }
}

API

createDrizzleTxAdapter(db)

Drizzle DB 인스턴스를 받아 TxAdapter를 반환합니다.

import { createDrizzleTxAdapter } from "@croco/tx-drizzle";

const adapter = createDrizzleTxAdapter(db);

반환된 어댑터는 다음을 지원합니다:

  • transaction(fn, options?): db.transaction 호출
  • savepoint(client, fn, options?): tx.transaction 호출 (중첩 트랜잭션). 런타임 transaction client가 transaction()을 제공하지 않으면 SavepointUnsupportedProblem으로 즉시 실패
  • supportsSavepoint(): true 반환. 단, 실제 중첩 트랜잭션 실행은 런타임 transaction client의 transaction() 지원이 필요

타입 유틸리티

import { InferTxClient, InferTxOptions } from "@croco/tx-drizzle";

type TxClient = InferTxClient<typeof db>;
type TxOptions = InferTxOptions<typeof db>;

Dialect 지원

이 패키지는 dialect-agnostic으로 설계되어 Drizzle이 지원하는 모든 데이터베이스에서 동작합니다:

  • PostgreSQL
  • MySQL
  • SQLite

각 dialect의 트랜잭션 옵션은 Drizzle의 타입 시그니처에서 자동으로 추론됩니다.

Peer Dependencies

  • drizzle-orm >=0.30.0