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

@usereq/database

v0.1.8

Published

Drizzle ORM schema and a Postgres client factory for Node.js runtime using `postgres` (`drizzle-orm/postgres-js`). Optional [read replicas](https://orm.drizzle.team/docs/read-replicas) and optional [Upstash Redis query cache](https://orm.drizzle.team/docs

Readme

@usereq/database

Drizzle ORM schema and a Postgres client factory for Node.js runtime using postgres (drizzle-orm/postgres-js). Optional read replicas and optional Upstash Redis query cache are supported.

Requirements

  • Node.js runtimecreateDatabase uses postgres and is compatible with Node.js server runtimes (including Next.js).
  • drizzle-orm — listed as a peerDependency; install a compatible version in the app that consumes this package (same major/minor range as this package’s peerDependencies).

Install

npm install @usereq/database drizzle-orm postgres
# or
bun add @usereq/database drizzle-orm postgres

If you use Upstash cache, also install the Redis client Drizzle’s cache layer expects:

bun add @upstash/redis

Schema

  • users — id, email, name, role, ban fields
  • accounts, sessions, verifications — auth-related tables
  • organizations, members, invitations — org and membership tables

Schema is exported from the package root and from @usereq/database/schema if you only need types/tables for migrations.

Usage

createDatabase is async. You can pass a connection string or a config object.

Primary only

import { createDatabase, users } from "@usereq/database";
import { eq } from "drizzle-orm";

const db = await createDatabase(process.env.DATABASE_URL!);

const [user] = await db.select().from(users).where(eq(users.id, userId));

Optional Upstash cache

Install @upstash/redis. Reads that use Drizzle’s cache APIs can be backed by Upstash; url and token are your REST credentials.

const db = await createDatabase({
  connectionString: process.env.DATABASE_URL!,
  cache: {
    url: process.env.UPSTASH_REDIS_REST_URL!,
    token: process.env.UPSTASH_REDIS_REST_TOKEN!,
    global: true, // optional; defaults to true in this package
  },
});

Optional read replicas

Pass one or more replica connection strings. Drizzle routes read-style operations to replicas and writes to the primary.

const db = await createDatabase({
  connectionString: process.env.DATABASE_URL!,
  replicas: [
    process.env.DATABASE_REPLICA_URL_1!,
    process.env.DATABASE_REPLICA_URL_2!,
  ],
  // cache is optional here too
});

Migrations (drizzle-kit)

This package does not ship drizzle-kit or migration files. Your application repo should depend on drizzle-kit, set DATABASE_URL (or read it from env), and point schema at the installed package:

// drizzle.config.ts (in your app)
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  dialect: "postgresql",
  schema: "./node_modules/@usereq/database/src/schema/index.ts",
  out: "./drizzle",
  dbCredentials: { url: process.env.DATABASE_URL! },
});

Adjust schema if you use a different package manager layout (for example a monorepo path or a re-export file that imports from @usereq/database/schema).

Publishing to npm (org scope)

  1. Org and scope — On npmjs.com, create an organization (for example usereq). Scoped packages use the name @usereq/database; the org owner or members need publish rights for that scope.

  2. Login locally

    npm login

    Ensure the logged-in user is allowed to publish @usereq/*.

  3. Version — Bump "version" in package.json (or use npm version patch|minor|major).

  4. Dry run — See what would be published:

    npm pack --dry-run

    Only files listed under "files" in package.json (plus package.json and README.md by npm rules) are included.

  5. Publish — Public scoped packages must use public access:

    npm publish --access public

    publishConfig.access is already set to "public" in this package, so npm publish is enough once your account defaults allow it; --access public is explicit and safe for first-time scoped publishes.

  6. CI (optional) — See GitHub Actions below.

After publish, consumers install with:

npm install @usereq/database drizzle-orm postgres
# or
bun add @usereq/database drizzle-orm postgres

GitHub Actions

Workflows live under .github/workflows/ in this repository.

| Workflow | Trigger | What it does | |----------|---------|----------------| | ci.yml | Push / PR to main or master | bun install --frozen-lockfile, bun run check-types. | | publish.yml | Push a version tag matching v* (e.g. v0.1.1) | Same checks, then npm publish --access public to the npm registry. |

Repository secret: add NPM_TOKEN (npm automation or granular token with publish rights for @usereq/database, and bypass 2FA if your account requires it). GitHub → Settings → Secrets and variables → Actions.

Release flow: bump version in package.json, commit, create and push a tag:

git tag v0.1.2
git push origin v0.1.2

The publish workflow runs on the tagged commit; the tag should match the version you intend to ship.