Registry / database / drizzle-orm-helpers

drizzle-orm-helpers

JSON →
library0.7.6jsnpmunverified

A collection of unofficial TypeScript-friendly helpers for Drizzle ORM, focused on providing common SQL/dialect-specific values, functions, operators, and column types. Current version is 0.7.6, under active development with frequent releases, primarily targeting PostgreSQL. Unlike official Drizzle ORM packages, these helpers are user-contributed and provisional, intended as stopgaps until official implementations are available. Dependencies include zod (>=3.23.8) and drizzle-orm (>=0.31.2).

npm install drizzle-orm-helpers
INSTALL
IMPORT
SIG · DRIZZLE-ORM-HELPER
D
drizzle-orm-helpers
databasejavascriptv0.7.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jsonObjectAgg
✓ import { jsonObjectAgg } from 'drizzle-orm-helpers'
✗ const { jsonObjectAgg } = require('drizzle-orm-helpers')
Package is ESM-only; using require() will fail. Use TypeScript for better type inference.
jsonBuildObject
✓ import { jsonBuildObject } from 'drizzle-orm-helpers'
Commonly used alongside jsonObjectAgg. Must be imported separately.
getColumns
✓ import { getColumns } from 'drizzle-orm-helpers'
Helper to extract column selection from a table definition.
textenum
✓ import { textenum } from 'drizzle-orm-helpers'
✗ import { textEnum } from 'drizzle-orm-helpers'
Function name is all lowercase 'textenum', not camelCase 'textEnum'.
nanoid
✓ import { nanoid } from 'drizzle-orm-helpers'
Generates nanoid strings; accepts options like { size: 12 }.
$true
✓ import { $true } from 'drizzle-orm-helpers'
Represents TRUE SQL value; used in joins with no condition.

Demonstrates aggregating translations and using custom column types with Drizzle ORM helpers.

import { drizzle } from 'drizzle-orm/node-postgres'; import { pgTable, text } from 'drizzle-orm/pg-core'; import { jsonObjectAgg, jsonBuildObject, getColumns, textenum, nanoid, $true } from 'drizzle-orm-helpers'; const languages = pgTable('languages', { lang: textenum('lang', { enum: ['fr', 'en'] as const }), }); const projects = pgTable('projects', { id: text('id').default(nanoid({ size: 12 })).primaryKey(), name: text('name'), }); export async function aggExample(db: ReturnType<typeof drizzle>) { const result = await db .select({ ...getColumns(projects), translations: jsonObjectAgg(languages.lang, jsonBuildObject({ lang: languages.lang })), }) .from(projects) .leftJoin(languages, $true) .groupBy(projects.id); return result; }
Debug
Known issues
breakingPackage is under heavy development; APIs may change without notice in minor versions.
fix
Pin exact version and test upgrades thoroughly.
affects: >=0.0.0
gotchaMost helpers are oriented towards PostgreSQL; MySQL and SQLite support may be limited or incomplete.
fix
Verify each helper works on your dialect; consider using official Drizzle ORM functions for cross-dialect needs.
affects: >=0.0.0
gotchaThe textenum function is not typed to infer the enum type from the array; you must provide a const assertion.
fix
Use 'as const' when passing the enum array to textenum.
affects: >=0.0.0
deprecatedSome helpers may be replaced by official Drizzle ORM functions; check documentation for deprecation notices.
fix
Monitor official Drizzle ORM releases for equivalent functionality and plan migration.
affects: >=0.5.0
Errors
Common errors & fixes
Cannot find module 'drizzle-orm-helpers' or its corresponding type declarations.
Package is ESM-only and may require 'type': 'module' in package.json or use of .mjs extension.
fix
Ensure your project is configured for ESM: set 'type': 'module' in package.json, or import as .mjs file.
jsonObjectAgg is not a function
Incorrect import - trying to use jsonObjectAgg without importing it, or using CommonJS require.
fix
Use ES module import: import { jsonObjectAgg } from 'drizzle-orm-helpers'
Property 'lang' does not exist on type 'PgTableWithColumns<...>'
Using getColumns on a table that doesn't have a 'lang' column in the helper functions.
fix
Ensure the table passed to helpers like jsonObjectAgg or joinTranslations includes the referenced columns.
Upgrade
Version history
0.7.6latest on npm
Audit
Dependencies
zodrequiredpeer dependency for schema validation
drizzle-ormrequiredpeer dependency; the helpers extend Drizzle ORM functionality
Agent activity
7 hits · last 30 days
node
6
Resources
drizzle-orm-helpers — npm install drizzle-orm-helpers · libregistry