@atscript/db-postgres
v0.1.50
Published
PostgreSQL adapter for @atscript/db with pg (node-postgres) driver support.
Downloads
1,298
Maintainers
Readme
PostgreSQL adapter for @atscript/db using the pg (node-postgres) driver. Full-featured with pgvector, CITEXT, GIN fulltext, HNSW indexes, transactional DDL, and batched inserts with RETURNING.
Includes PostgresPlugin for @db.pg.* annotations (type overrides, schema selection, native collation).
Installation
pnpm add @atscript/db-postgres pgQuick Start
import { DbSpace } from "@atscript/db";
import { createAdapter } from "@atscript/db-postgres";
const db = createAdapter("postgresql://user@localhost:5432/mydb");
const users = db.getTable(UsersType);
await users.insertOne({ name: "Alice", email: "[email protected]" });Features
- Full CRUD with batched multi-row INSERT + RETURNING (auto-chunking at ~65K params)
- pgvector: HNSW indexes with cosine, euclidean, and dot product similarity
- CITEXT for case-insensitive text via
@db.collate "nocase" - GIN fulltext search via
tsvector/tsquerywith ranking - GENERATED BY DEFAULT AS IDENTITY for auto-increment
- Native UUID generation via
gen_random_uuid() - Schema selection via
@db.pg.schema - Transactional DDL — schema sync is fully atomic
- Foreign key constraints with referential actions
- Full schema sync: CREATE, ALTER, DROP, indexes, views
Documentation
License
MIT
