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

drizzle-more

v0.1.3

Published

A collection of utilities for Drizzle ORM.

Readme

drizzle-more

A collection of utilities for Drizzle ORM for non-trivial but still common uses.

Installation

npm install drizzle-more

or

pnpm add drizzle-more

API

sqliteEnum

Creates a SQLite enum-like column with runtime validation. Since SQLite lacks native enum support, this uses a TEXT column that validates values on insert/update.

import { sqliteEnum } from 'drizzle-more';

const users = sqliteTable('users', {
  id: integer('id').primaryKey(),
  status: sqliteEnum(['active', 'inactive', 'pending'] as const, 'status').notNull(),
});

Throws an error if an invalid value is provided.


paginateQuery

Applies pagination to a Drizzle query. Supports page-based or offset-based pagination.

import { paginateQuery } from 'drizzle-more';

// Page-based (page 2, 10 items per page)
const results = await paginateQuery(db.select().from(users), { page: 2, limit: 10 });

// Offset-based (skip 20, take 10)
const results = await paginateQuery(db.select().from(users), { offset: 20, limit: 10 });

Page-based: { page: number, limit: number }page is 1-indexed, offset is calculated automatically.

Offset-based: { offset: number, limit: number } — specify the exact number of records to skip.


paginateWithTotal

Paginates a query and returns both the data and total count—useful for building paginated UIs.

import { paginateWithTotal } from 'drizzle-more';

const { total, data } = await paginateWithTotal(db, db.select().from(users), {
  page: 1,
  limit: 10,
});

const totalPages = Math.ceil(total / 10);

Returns: { total: number, data: T[] }

⚠️ Note: This function executes 2 queries sequentially (one for count, one for data). Use with caution in performance-critical scenarios.


stackedWhereQuery

Drizzle ORM's .where() replaces any previous condition. To combine conditions, you must wrap them in and(...):

// Without stackedWhereQuery - must use and() explicitly
const results = await db.select().from(users)
  .where(and(eq(users.status, 'active'), gt(users.age, 18)));

This becomes unwieldy when building queries conditionally. stackedWhereQuery lets you call .where() multiple times—conditions are automatically combined with AND:

import { stackedWhereQuery } from 'drizzle-more';
import { eq, gt } from 'drizzle-orm';

// Basic usage - chain multiple where calls
const results = await stackedWhereQuery(db.select().from(users).$dynamic())
  .where(eq(users.status, 'active'))
  .where(gt(users.age, 18));
// Conditional filtering
const query = stackedWhereQuery(db.select().from(users).$dynamic());

if (filterByStatus) query.where(eq(users.status, 'active'));
if (filterByAge) query.where(gt(users.age, 18));

const results = await query;

Combining Query Utilities

Use stackedWhereQuery with paginateWithTotal for filtered, paginated results:

import { stackedWhereQuery, paginateWithTotal } from 'drizzle-more';
import { eq, gt } from 'drizzle-orm';

const query = stackedWhereQuery(db.select().from(users).$dynamic())
  .where(eq(users.status, 'active'))
  .where(gt(users.age, 18));

const { total, data } = await paginateWithTotal(db, query, { page: 1, limit: 10 });

License

MIT