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;
}
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.
fixEnsure 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.
fixUse 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.
fixEnsure the table passed to helpers like jsonObjectAgg or joinTranslations includes the referenced columns.
Audit
Dependencies
zodrequiredpeer dependency for schema validation
drizzle-ormrequiredpeer dependency; the helpers extend Drizzle ORM functionality