Registry / database / zol-json

zol-json

JSON →
library0.5.1jsnpmunverified

JSON SQL query building for Zol ORM. This package provides TypeScript-first utilities to construct SQL JSON functions like json_agg, json_build_object, and row_to_json using Zol's query builder. Currently at version 0.5.1, it is released on npm intermittently as part of the Zol ecosystem. Key differentiator: tight integration with Zol's type-safe query interface, enabling typed JSON aggregation without raw SQL strings.

npm install zol-json
INSTALL
IMPORT
SIG · ZOL-JSON
Z
zol-json
databasejavascriptv0.5.1
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.

default
import zolJson from 'zol-json'
const zolJson = require('zol-json')
ESM-only; TypeScript type definitions included.
jsonAgg
import { jsonAgg } from 'zol-json'
const { jsonAgg } = require('zol-json')
Named export works in both ESM and CJS if module resolution allows, but prefer ESM.
jsonBuildObject
import { jsonBuildObject } from 'zol-json'
const jsonBuildObject = require('zol-json').jsonBuildObject
CommonJS require of named exports works but is less ergonomic.

Build a SQL query with JSON functions using Zol query builder.

import zol from 'zol'; import { jsonAgg, jsonBuildObject } from 'zol-json'; const db = zol(process.env.DATABASE_URL ?? ''); const users = db.selectFrom('users') .select([ 'id', 'name', jsonBuildObject({ email: 'email', age: 'age' }).as('profile'), jsonAgg('id').as('all_ids') ]) .where('age', '>', 18) .execute(); console.log(await users);
Debug
Known issues
gotchaExport names are subject to change before 1.0; check TypeDoc for exact names.
fix
Pin exact version and read changelog before upgrading.
affects: <1.0
deprecatedThe function 'jsonObject' was renamed to 'jsonBuildObject' in 0.4.0.
fix
Replace 'jsonObject' with 'jsonBuildObject' in imports and usage.
affects: <0.4.0
gotchaRequires peer dependency 'zol' at same version; missing or mismatched zol version causes runtime errors.
fix
Ensure 'zol' is installed and version matches 'zol-json' exactly.
affects: *
gotchaFunctions only work with PostgreSQL; no other SQL dialects supported.
fix
Use only with PostgreSQL database.
affects: *
Errors
Common errors & fixes
Cannot find module 'zol-json'
Package not installed or not in node_modules
fix
Run 'npm install zol-json' and ensure project name is correct.
TypeError: zol_1.default is not a function
CommonJS require used instead of ESM import for zol
fix
Use 'import zol from 'zol'' instead of 'const zol = require('zol')'.
jsonBuildObject is not importable
Wrong version; jsonBuildObject introduced in 0.4.0
fix
Upgrade to version >=0.4.0: 'npm install zol-json@^0.4.0'.
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies
zolrequiredPeer dependency: core ORM required for query building
Agent activity
37 hits · last 30 days
node
32
OpenAI (training)
1
Resources
zol-json — npm install zol-json · libregistry