Registry / database / morbid-postgres

morbid-postgres

JSON →
library1.0.4jsnpmunverified

Morbid is a schema-aware TypeScript query builder for PostgreSQL that generates TypeScript definitions from your database schema using a CLI tool. Version 1.0.4 is current; project is in early development (work in progress, not production-ready). It differentiates from Knex.js by providing strong type safety out of the box via schema extraction, transactions with isolation levels, and chainable query methods. Release cadence is low; community contributions welcome.

npm install morbid-postgres
INSTALL
IMPORT
SIG · MORBID-POSTGRES
M
morbid-postgres
databasejavascriptv1.0.4
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.

Generate
import { Generate } from 'morbid'
const Generate = require('morbid').Generate
ESM-only; named export for schema extraction CLI function
Morbid
import { Morbid } from 'morbid'
import Morbid from 'morbid'
ESM-only; named export of the main class, not default
Def
import { Def } from './output-definition'
const Def = require('./output-definition')
Generated file; must be imported as a TypeScript module

Generates TypeScript definitions from PostgreSQL schema, then uses Morbid to perform queries and transactions.

import { Generate, Morbid } from 'morbid'; import { Pool } from 'pg'; import { Def } from './output-definition'; const pool = new Pool({ host: process.env.PGHOST ?? 'localhost', user: process.env.PGUSER ?? 'postgres', password: process.env.PGPASSWORD ?? '', database: 'test_extract', }); // Generate schema definitions (run once) await Generate({ destination: 'output-definition', pg: pool, schemas: ['public'], }); type Customization = { __override__: { uuid: string }; tables: { account: { data: { email: string } } }; }; const morbid = new Morbid<typeof Def, Customization>(Def, pool); // Query examples const rows = await morbid.tables.account.select().where({ id: 1 }).run(); console.log(rows); // Transaction example const trx = await morbid.startTransaction({ isolation: 'serializable' }); await morbid.tables.account.insert({ name: 'test' }).run(trx); await trx.commit(); await pool.end();
Debug
Known issues
gotchaProject is a work in progress: not production-ready, API may break without notice.
fix
Do not use in production; pin exact version if you must use.
affects: <=1.0.4
deprecatedNo deprecation notices yet — all APIs are experimental.
fix
N/A
affects: <=1.0.4
gotchaESM-only package; using require() will fail.
fix
Use import syntax and ensure your project is configured for ESM.
affects: >=1.0.0
gotchaThe Generate function creates a .ts file but does not add .ts extension in the destination option; you must add it manually when importing.
fix
Import using the generated file name with .ts extension (e.g., './output-definition.ts').
affects: <=1.0.4
Errors
Common errors & fixes
TypeError: morbid.Morbid is not a constructor
Incorrect import: using default import instead of named import.
fix
Change to: import { Morbid } from 'morbid'
Cannot find module 'morbid' or its corresponding type declarations.
Package not installed or missing types.
fix
Run: npm install morbid && npm install --save-dev @types/pg typescript
Error: Cannot find module './output-definition'
Generate function not run or file path incorrect.
fix
Run the Generate function with the correct destination and ensure the file exists.
Upgrade
Version history
1.0.4latest on npm
Audit
Dependencies
pgrequiredPostgreSQL client used for connecting to the database
typescriptrequiredTypeScript is required for type definitions and compilation
Agent activity
2 hits · last 30 days
node
2
Resources
morbid-postgres — npm install morbid-postgres · libregistry