Skip to content

bigalorm/bigal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

851 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

BigAl

NPM version node version Known Vulnerabilities

A PostgreSQL-optimized, type-safe TypeScript ORM for Node.js. BigAl uses a fluent builder pattern for queries, decorator-based models, and immutable query state. Built exclusively for Postgres — queries are tuned for Postgres performance with native support for JSONB, DISTINCT ON, subquery joins, and ON CONFLICT upserts.

Install

npm install bigal

You also need a PostgreSQL driver:

# Option 1: postgres-pool (recommended)
npm install postgres-pool

# Option 2: node-postgres
npm install pg

# Option 3: Neon serverless
npm install @neondatabase/serverless

Quick Start

import { column, primaryColumn, table, Entity, initialize, Repository } from 'bigal';
import { Pool } from 'postgres-pool';

@table({ name: 'products' })
class Product extends Entity {
  @primaryColumn({ type: 'integer' })
  public id!: number;

  @column({ type: 'string', required: true })
  public name!: string;

  @column({ type: 'integer', required: true, name: 'price_cents' })
  public priceCents!: number;
}

const pool = new Pool('postgres://localhost/mydb');
const repos = initialize({ models: [Product], pool });
const productRepository = repos.Product as Repository<Product>;

// Fluent queries — just await the chain
const products = await productRepository
  .find()
  .where({ priceCents: { '>=': 1000 }, name: { contains: 'widget' } })
  .sort('name asc')
  .limit(10);

// Upserts with ON CONFLICT
await productRepository.create({ name: 'Widget', sku: 'WDG-001', priceCents: 999 }, { onConflict: { action: 'merge', targets: ['sku'], merge: ['priceCents'] } });

Documentation

Full documentation is available at bigalorm.github.io/bigal.

Machine-Readable Documentation

BigAl provides machine-readable documentation for LLMs and AI-powered tools:

Resource URL
llms.txt bigalorm.github.io/bigal/llms.txt
llms-full.txt bigalorm.github.io/bigal/llms-full.txt

Agent skill

Install the BigAl agent skill for AI-assisted development:

npx skills add bigalorm/bigal

Compatibility

License

MIT

About

Type-safe PostgreSQL ORM for Node.js with a fluent query builder, decorator-based models, and queries tuned for Postgres performance.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

 

Contributors