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

@bunnykit/orm

v0.3.9

Published

An Eloquent-inspired ORM for Bun's native SQL client supporting SQLite, MySQL, and PostgreSQL.

Readme

Bunny

☕ Buy me a coffee

Bun-only package. Install with:

bun add @bunnykit/orm

npm, yarn, pnpm, and Node.js runtime usage are not supported.

An Eloquent-inspired ORM built specifically for Bun's native bun:sql client. It ships with zero runtime dependencies and supports SQLite, MySQL, and PostgreSQL with full TypeScript typing, a chainable query builder, schema migrations, model observers, polymorphic relations, and an interactive REPL.


Features

  • 🔥 Bun-native — Built on top of bun:sql for maximum performance
  • 🪶 Zero runtime dependencies — No package lock-in beyond Bun itself
  • 📦 Multi-database — SQLite, MySQL, and PostgreSQL support
  • 🔷 Fully TypedModel.define<T>() gives attribute access, typed with() autocomplete, and typed eager-load results with zero codegen
  • 🏗️ Schema Builder — Programmatic table creation, indexes, foreign keys
  • 🔍 Query Builder — Chainable where, join, orderBy, groupBy, date filters, conditional building, etc.
  • 🧠 Tagged Cache — Redis-backed cache facade, query remember(), and exact tag invalidation
  • 📣 Events — Application-level event dispatcher with function listeners and class handlers
  • 🐇 Queue Jobs — Database- and Redis-backed background job queue with named queues, retries, delays, and a bunny queue worker
  • 🛠️ Commands — Artisan-style CLI commands with a signature DSL, argument/option parsing, and bunny run
  • 🧬 Eloquent-style Models — Property attributes, defaults, casts, dirty tracking, soft deletes, scopes, find-or-fail, first-or-create
  • 🧺 Collections — Laravel-style helpers for multi-record query results
  • 🔗 Relations — Standard, many-to-many, polymorphic, through, one-of-many, and relation queries
  • 👁️ Observers — Lifecycle hooks (creating, created, updating, updated, etc.)
  • 🚀 Migrations & CLI — Create, run, reset, refresh, and inspect migrations from the command line
  • 🌱 Seeders & Factories — Run all seeders or target one seeder by name/file, plus lightweight model factories
  • 💬 REPL — Inspect models and run queries interactively with bunny repl
  • Streamingchunk, chunkById, cursor, each, eachById, and lazy for memory-efficient large dataset processing
  • 🏢 Multi-tenant — Database-per-tenant, schema-per-tenant, and RLS strategies with DB.tenant() and TenantContext

Installation

bun add @bunnykit/orm

See Installation for details.


Quickstart

Define a model with Model.define<T>() to get full IntelliSense on attributes, query builder columns, and eager-load results:

import { Model } from "@bunnykit/orm";

interface UserAttributes {
  id: number;
  name: string;
  email: string | null;
  created_at: string;
  updated_at: string;
}

class User extends Model.define<UserAttributes>("users") {
  posts() {
    return this.hasMany(Post);
  }
}

class Post extends Model.define<{ id: number; user_id: number; title: string }>("posts") {
  author() {
    return this.belongsTo(User);
  }
}

Point the ORM at a database and run a query:

import { Connection, Model } from "@bunnykit/orm";

Model.setConnection(new Connection({ url: "sqlite://app.db" }));

const users = await User.where("email", "[email protected]")
  .with("posts")
  .get();

for (const user of users) {
  console.log(user.name, user.posts.length);
}

Or use the DB facade for ad-hoc table access without a model:

import { DB } from "@bunnykit/orm";

const rows = await DB.table("audit_logs")
  .where("event", "login")
  .orderBy("created_at", "desc")
  .limit(10)
  .get();

See the Quickstart guide for the full walkthrough.


Documentation

Getting Started

| Topic | Summary | |---|---| | Installation | Add the package to your Bun project. | | Configuration | Connection, tenancy, migrations, seeders, type generation. | | Quickstart | End-to-end walkthrough: install → config → migration → model → query. |

Database

| Topic | Summary | |---|---| | Schema Builder | Tables, columns, indexes, foreign keys. | | Migrations | Versioned schema changes, rollback, multi-tenant scopes, auto-create database / schema. | | Seeders | Populate development and test data. | | Transactions | connection.transaction() and nested savepoints. |

Querying

| Topic | Summary | |---|---| | Query Builder | Chainable where / join / with / aggregates, DB facade, raw queries. | | Cache | Redis-backed cache API, query remember(), exact tag invalidation. | | Collections | map, filter, groupBy, and other helpers returned by get(). | | Models | Defining models, casts, accessors, soft deletes, persistence. | | Relationships | hasMany, belongsTo, belongsToMany, polymorphic, eager loading. | | Validation | Typed Laravel-style validator with fluent rules and tenant-aware database checks. |

TypeScript

| Topic | Summary | |---|---| | TypeScript | Model.define<T>(), typed builders, scope and accessor typing. | | Type Generation | Generate attribute interfaces from your database schema. |

Background Processing

| Topic | Summary | |---|---| | Queue Jobs | Dispatch jobs to named queues, run workers with bunny queue, retries, delays, failed-job tracking, database and Redis drivers. | | Commands | Artisan-style CLI commands with signature DSL, argument/option parsing, output helpers, and bunny run. |

Advanced

| Topic | Summary | |---|---| | SvelteKit Helper | Typed route model binding and action validation helpers for +page.server.ts. | | Policies | Register model/resource policies, use can / authorize, and enforce access in RouteBuilder. | | Observers | Lifecycle hooks for creating, updating, deleting, and more. | | Events | Application-level events with function listeners, class handlers, and temporary subscriptions. | | Library Usage | Programmatic API via configureBunny(). | | Testing | In-memory SQLite and transactional test isolation. |

The full index lives at docs/README.md.


License

MIT