@postgresql-typed/core
v0.15.1
Published
A type-safe PostgreSQL client for Node.js
Downloads
223
Maintainers
Readme
npm install --save @postgresql-typed/core
import { Client, pgt, table } from "@postgresql-typed/core";
import {
defineCharacterVarying,
defineInt2,
defineUUID
} from "@postgresql-typed/core/definers";
import { eq } from "@postgresql-typed/core/operators";
const db = pgt(new Client({
connectionString: "postgres://user:pass@localhost:5432/dbname"
}));
await db.connect();
const users = table("users", {
id: defineUUID("user_id").primaryKey(),
name: defineCharacterVarying("user_name", {
length: 255
}).notNull(),
age: defineInt2("user_age").notNull()
});
await db.select().from(users).where(eq(users.age, 18));