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)
Errors
Common errors & fixes
TypeError: (0 , zol_1.query) is not a function
Incorrect import – using zol.query instead of named import 'query'.
fiximport { query } from 'zol' Cannot find module 'pg' or its corresponding type declarations.
Missing peer dependency pg or its types.
fixnpm 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.
fixEnsure 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.).
fixUse zol types: import { text, integer, serial } from 'zol' and define columns with those functions. Audit
Dependencies
pgrequiredRuntime PostgreSQL driver – peer dependency >=8 <9