Registry / database / tusken

tusken

JSON →
library0.1.0jsnpmunverified

A TypeScript-native Postgres client with code generation capabilities. Version 0.1.0 is the initial release, offering a query builder and type-safe SQL execution. It differentiates itself by generating TypeScript types from your database schema, reducing boilerplate and runtime errors. Built on top of the popular 'pg' driver, it requires peer dependencies 'pg', 'postgres-interval', and 'postgres-range'. Still in early development, with a focus on developer experience and type safety.

npm install tusken
INSTALL
IMPORT
SIG · TUSKEN
T
tusken
databasejavascriptv0.1.0
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.

tusken
import { tusken } from 'tusken'
import tusken from 'tusken'
Named export, not default.
sql
import { sql } from 'tusken'
const sql = require('tusken').sql
ESM-only; use named import.
PgClient
import { PgClient } from 'tusken'
import PgClient from 'tusken'
Named export for the client class.

Connects to Postgres using environment variables, runs a parameterized query, and closes the connection.

import { tusken, sql } from 'tusken'; const db = tusken({ host: process.env.PGHOST ?? 'localhost', port: parseInt(process.env.PGPORT ?? '5432'), database: process.env.PGDATABASE ?? 'mydb', user: process.env.PGUSER ?? 'user', password: process.env.PGPASSWORD ?? '', }); async function main() { const result = await db.query(sql`SELECT * FROM users WHERE id = ${1}`); console.log(result.rows); await db.end(); } main().catch(console.error);
Debug
Known issues
breakingtusken is in version 0.x and API may change without major version bump.
fix
Pin to a specific version and test upgrades.
affects: <1.0.0
gotchaPeer dependency 'pg' must be installed separately; tusken does not bundle it.
fix
Run 'npm install pg' alongside tusken.
affects: >=0.1.0
gotchaUsing 'require' style imports will fail because tusken is ESM-only.
fix
Use 'import' syntax or ensure your project is configured for ESM.
affects: >=0.1.0
gotchaThe 'sql' tagged template literal only works with tusken's query method; passing to other libraries may break.
fix
Always use 'db.query(sql`...`)' for parameterized queries.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'tusken'
Package not installed or not in node_modules.
fix
Run 'npm install tusken pg'
TypeError: db.query is not a function
Did not initialize tusken client correctly.
fix
Make sure to call 'tusken(options)' and use the returned object.
SyntaxError: Named export 'tusken' not found. The requested module 'tusken' is a CommonJS module...
Using named imports in a CJS context or wrong import syntax.
fix
Use 'import { tusken } from 'tusken'' in an ESM context, or switch to a bundler that supports ESM.
Module 'pg' is required but not installed
Missing peer dependency 'pg'.
fix
Run 'npm install pg'.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
pgrequiredPostgreSQL driver for Node.js
postgres-intervaloptionalInterval type support for Postgres
postgres-rangeoptionalRange type support for Postgres
Agent activity
22 hits · last 30 days
node
18
Meta
2
OpenAI (training)
1
Resources
packagetusken
tusken — npm install tusken · libregistry