Postgres Data Objects (PDO) is a lightweight TypeScript-first ORM for PostgreSQL that provides a clean, class-based interface for database operations. Current stable version is 0.1.3. It focuses on type safety and developer experience by leveraging TypeScript generics for compile-time query validation. Key differentiators include automatic schema inference from database tables, built-in migration support, and zero-configuration setup for common use cases. Unlike heavier ORMs like TypeORM or Prisma, PDO aims to be minimal with no external runtime dependencies beyond the 'pg' driver. Release cadence is irregular as it is still in early development.
npm install postgres-pdoNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Connect to a PostgreSQL database, define a User model with a table decorator, and query users by name pattern.
Update all .where() calls to include operator as second argument: .where('field', '=', 'value')Use 'pwd' instead of 'password' in connection config: { ..., pwd: 'secret' }Replace Model.all() with Model.query().get()
Always call await pdo.connect() at startup and await pdo.disconnect() when done.
Add exclamation marks: id!: number; or use constructor to initialize.
Remove imports from 'postgres-pdo/types'; all types are now exported from main package.
Replace pdo.raw(sql) with Model.query().raw(sql) or use the query builder methods.
Change config key from 'password' to 'pwd'
Use import { PDO } from 'postgres-pdo' instead of import PDO from 'postgres-pdo'Ensure your class extends Model and has @Table decorator: class User extends Model { ... }Ensure PostgreSQL is started and connection settings are correct. Use environment variables for host, port.
Add ! to property declaration: id!: number;