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

@boxdb/drizzle-adapter

v0.5.1

Published

Asynchronous Drizzle ORM adapter for BoxDB

Downloads

1,065

Readme

BoxDB adapter for Drizzle

An asynchronous SQLite driver for Drizzle 0.45.x. Install @boxdb/client, @boxdb/drizzle-adapter, and drizzle-orm.

npm install @boxdb/client @boxdb/drizzle-adapter drizzle-orm
import { BoxDB } from "@boxdb/client";
import { createDrizzleDatabase, migrate } from "@boxdb/drizzle-adapter";
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";

const users = sqliteTable("users", {
  id: integer().primaryKey({ autoIncrement: true }).$type<bigint>(),
  name: text().notNull(),
});
await using client = await BoxDB.open("data.db");
const db = createDrizzleDatabase(client, { schema: { users } });
await migrate(db, { migrationsFolder: "./drizzle" });
const rows = await db.insert(users).values({ name: "Ada" }).returning();

The driver supports relational queries, joins, prepared Drizzle queries, RETURNING, and atomic batch. Drizzle transaction callbacks use BoxDB transaction handles internally; nested callbacks use savepoints. You can also pass an existing BoxDB transaction to createDrizzleDatabase.

Write metadata and integer cells remain bigint. Use integer().$type<bigint>() for Drizzle integer columns. Boolean columns map to boolean and timestamp columns map to Date, without converting unrelated integer cells. Migrations use an INTEGER journal and apply SQL and journal entries in one transaction.

The adapter borrows $client; close it yourself or use await using. For cancellation across Drizzle work, open a BoxDB transaction with a signal and create the Drizzle database from its handle. Base-client ownership rules apply when mixing Drizzle and direct SQL.

BoxDB columns

Declare extended types with the adapter's column builders:

import { decimal, instant, json, uuid } from "@boxdb/drizzle-adapter";

const invoices = sqliteTable("invoices", {
  id: uuid().primaryKey(),
  amount: decimal({ precision: 20, scale: 2 }).notNull(),
  createdAt: instant("created_at").notNull(),
  details: json().$type<{ reference: string }>(),
});

decimal, uuid, instant, date, time, dateTime and interval use strings for parameters and results. BoxDB validates and normalizes values in the declared SQL columns; exact decimals and temporal microseconds survive without conversion to JavaScript Number or Date. Builders expose the native SQL declarations for schema generation. time("opens") declares a TIME column, using values such as "09:30:00.000000" without a date or zone. Create matching columns through BoxDB migrations.

json serializes and parses complete documents in the client. $type<T>() describes the application type; it does not validate that shape at runtime. SQL NULL remains null. JSON/JSONB SQL inspection and editing are unsupported.