PostgreSQL provider for @romatech/orm. Full CRUD, server-side WHERE/ORDER BY generation, migrations, scaffold, and parameterised queries.
Installation
npm install @romatech/orm @romatech/orm-providers-pgsql reflect-metadata
Quick Start
import 'reflect-metadata';
import { DbContext, DbContextOptions } from '@romatech/orm';
import { PgSqlProvider } from '@romatech/orm-providers-pgsql';
class AppDbContext extends DbContext {
users = this.set(User);
constructor() {
super(
new DbContextOptions().useProvider(
new PgSqlProvider({
host: 'localhost',
port: 5432,
user: 'postgres',
password: 'yourPassword',
database: 'mydb'
})
)
);
}
}
Features
Full CRUD
add, addRange, update, remove, removeRange, find, getAll — all with change tracking.
Server-side SQL
WHERE and ORDER BY clauses generated from predicates. $1, $2 positional parameters (SQL injection safe).
Migrations
Migration history table, createTable with IF NOT EXISTS, dropTable, addColumn, removeColumn.
Scaffold
Introspect via pg_tables and information_schema.columns to generate entity files.
Connection Options
Object-style config or PostgreSQL connection string (postgresql://user:pass@host/db).
PostgreSQL 12+
Requires Node.js ≥ 18. Uses the pg package (installed automatically).