Registry / database / ts-postgres-model

ts-postgres-model

JSON →
library0.2.3jsnpmunverified

A TypeScript abstract class for creating PostgreSQL model classes that provides a structured base for database operations. Current stable version is 0.2.3, but development appears minimal with no recent updates. It offers a lightweight ORM-like abstraction with TypeScript type safety, but compared to mature alternatives like TypeORM or Sequelize, it lacks features, documentation, and community support. Suitable only for early-stage prototyping.

npm install ts-postgres-model
INSTALL
IMPORT
SIG · TS-POSTGRES-MODEL
T
ts-postgres-model
databasejavascriptv0.2.3
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.

Model
import { Model } from 'ts-postgres-model'
import Model from 'ts-postgres-model'
Named export, not default.
Model
const { Model } = require('ts-postgres-model')
const model = require('ts-postgres-model')
CommonJS destructuring required.
Model class methods
class User extends Model { ... }
class User implements Model { ... }
Model is an abstract class, not an interface.

This shows how to extend the Model class, define a custom static method, and use it.

import { Pool } from 'pg'; import { Model } from 'ts-postgres-model'; const pool = new Pool(); class User extends Model { static tableName = 'users'; static async findByName(name: string) { const result = await this.query('SELECT * FROM users WHERE name = $1', [name]); return result.rows[0]; } } (async () => { const user = await User.findByName('Alice'); console.log(user); await pool.end(); })();
Debug
Known issues
gotchaPackage has very few downloads and no updates since initial release.
fix
Consider using a more mature ORM like TypeORM or Prisma.
affects: 0.2.3
gotchaMinimal documentation; only a README with basic example.
fix
Read the source code or use a better-documented library.
affects: 0.2.3
gotchaRequires manual pool management; no built-in connection handling.
fix
Pass an existing pool instance; ensure pool.end() is called.
affects: 0.2.3
Errors
Common errors & fixes
TypeError: this.query is not a function
Calling query on instance instead of class
fix
Use this.constructor.query() or define query as static.
Cannot find module 'ts-postgres-model'
Package not installed or import path incorrect
fix
Run npm install ts-postgres-model and check import statement.
Argument of type 'string' is not assignable to parameter of type 'never'
Generic type not specified when extending Model
fix
Define interface for row type and pass to Model<RowType>.
Upgrade
Version history
0.2.3latest on npm
Audit
Dependencies
pgrequiredPostgreSQL client for database connections
Agent activity
16 hits · last 30 days
node
12
Meta
2
Amazon
1
OpenAI (training)
1
Resources
ts-postgres-model — npm install ts-postgres-model · libregistry