Registry / database / zol
library0.5.1jsnpmunverified

A type-safe SQL abstraction layer for TypeScript and PostgreSQL, inspired by Selda and LINQ. Current stable version 0.5.1 is pre-1.0 with breaking changes expected. Offers composable query building with compile-time type safety, contrasting with runtime ORMs. Requires pg driver. Ships TypeScript definitions.

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

zol
import { zol } from 'zol'
const zol = require('zol')
ESM-only package; named import.
Table
import { Table } from 'zol'
Named export for defining table schemas.
query
import { query } from 'zol'
import { zol } from 'zol'; zol.query(...)
query is a separate named export, not a method on zol.
select
import { select } from 'zol'
Used for composing SELECT queries.
insert
import { insert } from 'zol'
For INSERT statements.

Shows table definition, query composition with typed columns, and execution with pg Pool.

import { zol, Table, query, select, insert, text, integer, serial } from 'zol' import { Pool } from 'pg' const pool = new Pool({ connectionString: process.env.DATABASE_URL ?? '' }) const users = new Table('users', { id: serial(), name: text(), age: integer() }) const getUsersOverAge = (age: number) => query(select(users.id, users.name, users.age)) .from(users) .where(users.age.gt(age)) .orderBy(users.name) async function run() { const client = await pool.connect() try { const rows = await getUsersOverAge(18).execute(client) console.log(rows) } finally { client.release() } } run().catch(console.error)
Debug
Known issues
breakingPre-1.0 releases may introduce breaking changes without major version bump.
fix
Pin exact version (e.g., "zol": "0.5.1") and review changelog before upgrading.
affects: <1.0.0
gotchaQuery execution requires a pg client (not a pool) directly – the .execute() method expects a Client, not Pool.
fix
Call pool.connect() to obtain a client, then pass it to .execute().
affects: >=0.0.0
gotchaTable columns are typed using the provided row schema; mismatched column names cause compile-time errors.
fix
Ensure column definitions match the actual database schema exactly.
affects: >=0.0.0
gotchaThe package does not create tables or migrations; it assumes the schema exists in the database.
fix
Use a migration tool (e.g., node-pg-migrate) to manage schema separately.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: (0 , zol_1.query) is not a function
Incorrect import – using zol.query instead of named import 'query'.
fix
import { query } from 'zol'
Cannot find module 'pg' or its corresponding type declarations.
Missing peer dependency pg or its types.
fix
npm install pg @types/pg
Property 'execute' does not exist on type 'QueryBuilder'.
Forgetting to call .query()? Actually execute is on the result of query(select(...)). Confirm version; early versions may not have execute.
fix
Ensure you are using zol >=0.5.0 and chain .execute(client) on the query.
Type 'string' is not assignable to type 'SqlType'.
Using string instead of zol's column type definitions (text(), integer(), etc.).
fix
Use zol types: import { text, integer, serial } from 'zol' and define columns with those functions.
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies
pgrequiredRuntime PostgreSQL driver – peer dependency >=8 <9
Agent activity
38 hits · last 30 days
node
34
OpenAI (training)
1
Resources
packagezol
zol — npm install zol · libregistry