@postgresql-typed/core
TypeScript icon, indicating that this package has built-in type declarations

0.15.1 • Public • Published

@PostgreSQL-Typed/Core

A type-safe PostgreSQL client for Node.js

Table of Contents Installation
Usage
Ecosystem
License

Installation

Install @postgresql-typed/core

npm install --save @postgresql-typed/core

Usage

This package is build on top of drizzle-orm, which is a type-safe ORM for Node.js.
For more information on how to use this package, please refer to the drizzle-orm documentation.
Differences between drizzle-orm and @postgresql-typed/core are listed below.

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));

There is no need to install pg, nor drizzle-orm as they are both dependencies of this package.
However, you will need to install @postgresql-typed/cli if you want to use the CLI to generate the table definitions.

Ecosystem

This package is part of the PostgreSQL-Typed ecosystem.

License

Mozilla Public License 2.0

Package Sidebar

Install

npm i @postgresql-typed/core

Weekly Downloads

163

Version

0.15.1

License

MPL-2.0

Unpacked Size

697 kB

Total Files

213

Last publish

Collaborators

  • bas950