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

@novahelm/db

v2026.6.2

Published

NovaHelm database — PostgreSQL connection wrapper with pgvector support.

Readme

@novahelm/db

Database package for NovaHelm — the connection wrapper and core schemas. Provides the client factory, the 60+ core platform tables, pgvector support, seed functions, and the migration runner.

Note on the ORM. This package historically wrapped Drizzle. Drizzle is being removed from the platform — new schemas must be declared with defineModel() from @novahelm/engine (see packages/engine/src/PATTERNS.md). The Drizzle APIs documented below survive only to serve the remaining core schemas while they are migrated; treat them as deprecated for new code.


Quick Start

pnpm add @novahelm/db
import { createDb } from "@novahelm/db";
import { initNova } from "@novahelm/core";

// 1. Create the database client
const db = createDb({ databaseUrl: env.DATABASE_URL });

// 2. Register with the Nova registry
initNova({ db, redis, auth, logger, config });

Then retrieve it anywhere:

import { getDb } from "@novahelm/core";
import type { NovaDb } from "@novahelm/db";

const db = getDb<NovaDb>();
const user = await db.query.users.findFirst({
  where: (u, { eq }) => eq(u.id, userId),
});

createDb Options

import { createDb } from "@novahelm/db";

const db = createDb({
  // Required: full PostgreSQL connection string
  databaseUrl: "postgres://user:pass@host:5432/mydb",

  // Optional: connection pool size (default: 20)
  max: 10,

  // Optional: log all SQL queries (default: false, dev only)
  logger: true,
});

| Option | Type | Default | Description | |--------|------|---------|-------------| | databaseUrl | string | -- | PostgreSQL connection string (required) | | max | number | 20 | Max connections in pool | | logger | boolean | false | Log SQL queries to stdout |


Schema

The package exports all Drizzle pgTable definitions. Consumers re-export them alongside their own extension tables:

// In your project's schema.ts
export * from "@novahelm/db/schema";
export * from "./my-extensions";

Schema Groups

Import via @novahelm/db/schema or from the main entry point:

| Group | Tables | |-------|--------| | Auth | users, sessions, accounts, verificationTokens | | RBAC | roles, rolePermissions, userRoles | | Tenants | tenants, tenantMembers | | Billing | subscriptions, billingEvents | | Commerce | products, productVariants, collections, productCollections, inventoryLevels, orders, orderItems, cart, cartItems, discounts, shippingZones, shippingRates, reviews | | Content | posts | | Media | media, mediaUsages | | AI | embeddings, conversations, messages | | Data Sources | dataSources, dataSyncLog | | Analytics | analyticsEvents, analyticsDaily, analyticsFunnels | | Engagement | contentSubscriptions, userInteractions, userPersonas, contentRelations, contentTags, pendingDigestItems, emailCampaigns, campaignSends | | Experiments | experiments, experimentAssignments, experimentConversions | | Remote Config | remoteConfigs, remoteConfigOverrides | | System | apiKeys, notifications, pushTokens, auditLog, featureFlags, feedback, onboardingProgress, notificationPreferences, accountDeletionRequests | | System Health | systemProbes, systemAlerts | | Performance | perfEvents, perfAggregates | | Relations | All Drizzle relations() definitions |

pgvector Support

The schema includes pgvector columns for AI embedding storage:

import { EMBEDDING_DIMENSIONS } from "@novahelm/db";

// Default: 1536 dimensions (OpenAI text-embedding-3-small)
// Change this constant when switching embedding models

Vector similarity helpers:

import { cosineSimilarity, l2Distance } from "@novahelm/db";

// Use in Drizzle queries for semantic search
const results = await db
  .select()
  .from(embeddings)
  .orderBy(cosineSimilarity(embeddings.vector, queryVector))
  .limit(10);

Seeding

Seed the database with default roles, permissions, admin user, feature flags, and sample content:

import { seedCore } from "@novahelm/db";

await seedCore(db, {
  // Optional: custom password hasher (uses bcrypt by default)
  hashPassword: async (password) => {
    return await hash(password);
  },
});

The seed creates:

  • 4 roles: Admin, Moderator, User, Viewer (with permissions)
  • 1 admin user: [email protected] / admin123
  • Default feature flags
  • Sample content

Migrations

Run pending Drizzle migrations at consumer app startup:

import { runProjectMigrations } from "@novahelm/db";

// Call before accepting requests
await runProjectMigrations(env.DATABASE_URL);

Migration files are bundled in the drizzle/ folder of the published package.

For development, use the CLI:

novahelm db push     # Push schema changes to dev database
novahelm db seed     # Run seedCore()
novahelm db studio   # Open Drizzle Studio

Subpath Exports

| Import Path | Description | |-------------|-------------| | @novahelm/db | Main entry: createDb, schemas, helpers, seed, migrations | | @novahelm/db/schema | Schema-only: all table definitions and relations |


API Reference

| Export | Description | |--------|-------------| | DB_VERSION | Current package version (CalVer) | | EMBEDDING_DIMENSIONS | Vector dimensions constant (default: 1536) | | createDb(options) | Create a Drizzle ORM database client | | NovaDb | Fully-typed Drizzle database type | | CreateDbOptions | Options for createDb() | | cosineSimilarity(col, vec) | Cosine similarity SQL helper | | l2Distance(col, vec) | L2 distance SQL helper | | seedCore(db, options?) | Seed database with defaults | | SeedOptions | Seed configuration type | | runProjectMigrations(url) | Run pending Drizzle migrations | | users, sessions, posts, ... | All Drizzle table definitions |