Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Atscript

@atscript/db-postgres

Define your models once — get TypeScript types, runtime validation, and DB metadata from a single .as model.

Documentation · PostgreSQL Adapter


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 pg

Quick 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: "alice@example.com" });

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 / tsquery with 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