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

@djs-core/plugin-drizzle

v1.0.3

Published

Drizzle ORM integration for djs-core. Supports SQLite, PostgreSQL, MySQL, and Turso with full type safety on `client.drizzle`.

Readme

@djs-core/plugin-drizzle

Drizzle ORM integration for djs-core. Supports SQLite, PostgreSQL, MySQL, and Turso with full type safety on client.drizzle.

Installation

djs-core plugin install @djs-core/plugin-drizzle

This will:

  • Add the plugin to your djs.config.ts
  • Create src/db/schema.ts with a starter schema
  • Create drizzle.config.ts configured for your dialect
  • Add the database file to .gitignore (SQLite only)

Setup

1. Configure the plugin

// djs.config.ts
import { defineConfig } from "@djs-core/runtime";

export default defineConfig({
  token: process.env.TOKEN!,
  servers: [],
  plugins: [import("@djs-core/plugin-drizzle")],
  pluginsConfig: {
    drizzle: {
      dialect: "sqlite", // "sqlite" | "postgresql" | "mysql" | "turso"
    },
  },
});

2. Define your schema

// src/db/schema.ts
import { int, sqliteTable, text } from "drizzle-orm/sqlite-core";

export const users = sqliteTable("users", {
  id: int().primaryKey({ autoIncrement: true }),
  name: text().notNull(),
  createdAt: int({ mode: "timestamp" }).$defaultFn(() => new Date()).notNull(),
});

3. Generate and run migrations

djs-core drizzle generate   # generate SQL migration files
djs-core drizzle migrate    # apply migrations to the database

4. Use in your commands

// src/interactions/commands/users/list.ts
import { Command } from "@djs-core/runtime";
import * as schema from "../../../db/schema";

export default new Command()
  .setName("users")
  .setDescription("List all users")
  .run(async (interaction) => {
    const users = await interaction.client.drizzle
      .select()
      .from(schema.users);

    await interaction.reply({
      content: users.map((u) => u.name).join("\n") || "No users found.",
    });
  });

Dialects

SQLite (default)

No extra dependencies needed — uses Bun's native SQLite driver.

pluginsConfig: {
  drizzle: {
    dialect: "sqlite",
    url: ".djscore/drizzle.db", // optional, this is the default
  },
},

PostgreSQL

bun add postgres
pluginsConfig: {
  drizzle: {
    dialect: "postgresql",
    url: process.env.DATABASE_URL, // or set DATABASE_URL in .env
  },
},
// src/db/schema.ts
import { pgTable, serial, text, timestamp } from "drizzle-orm/pg-core";

export const users = pgTable("users", {
  id: serial().primaryKey(),
  name: text().notNull(),
  createdAt: timestamp().defaultNow().notNull(),
});

MySQL

bun add mysql2
pluginsConfig: {
  drizzle: {
    dialect: "mysql",
    url: process.env.DATABASE_URL,
  },
},
// src/db/schema.ts
import { int, mysqlTable, text, timestamp } from "drizzle-orm/mysql-core";

export const users = mysqlTable("users", {
  id: int().primaryKey().autoincrement(),
  name: text().notNull(),
  createdAt: timestamp().defaultNow().notNull(),
});

Turso

bun add @libsql/client
pluginsConfig: {
  drizzle: {
    dialect: "turso",
    url: process.env.DATABASE_URL, // libsql://your-db.turso.io
    // TURSO_AUTH_TOKEN is read from env automatically
  },
},

Configuration

| Option | Type | Default | Description | |--------|------|---------|-------------| | dialect | "sqlite" \| "postgresql" \| "mysql" \| "turso" | "sqlite" | Database engine | | url | string | ".djscore/drizzle.db" (sqlite) | Connection URL or file path | | schema | string | "src/db/schema.ts" | Path to your schema file | | migrationsFolder | string | "drizzle" | Path to migrations folder | | autoMigrate | boolean | false | Apply pending migrations on startup |

CLI commands

| Command | Description | |---------|-------------| | djs-core drizzle generate | Generate SQL migration files from schema changes | | djs-core drizzle migrate | Apply pending migrations | | djs-core drizzle push | Push schema directly without migration files (dev only) | | djs-core drizzle pull | Pull schema from existing database | | djs-core drizzle studio | Open Drizzle Studio in the browser |

Auto-migrate

Setting autoMigrate: true runs pending migrations automatically when the bot starts.

pluginsConfig: {
  drizzle: {
    dialect: "sqlite",
    autoMigrate: true, // ⚠️ use with caution in production
  },
},

Warning — do not use autoMigrate in production without a deployment strategy. Prefer running djs-core drizzle migrate as part of your deploy pipeline.

Type safety

Run djs-core generate-config-types after adding or changing the plugin config to regenerate djs-core.d.ts. This gives client.drizzle the exact type for your schema and dialect.

// After generation, client.drizzle is fully typed:
const user = await client.drizzle.query.users.findFirst({
  where: (u, { eq }) => eq(u.id, 1),
}); // user: { id: number; name: string; createdAt: Date } | undefined