bigal 15.11.4 → 16.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## [16.0.0-beta.1](https://github.com/bigalorm/bigal/compare/v15.11.4...v16.0.0-beta.1) (2026-03-23)
2
+
3
+ ### ⚠ BREAKING CHANGES
4
+
5
+ - Function-based schema API
6
+
7
+ ### Features
8
+
9
+ - Function-based schema API ([5b67b83](https://github.com/bigalorm/bigal/commit/5b67b83c29cfe7b53b725415c0eeff175445ffac))
10
+
1
11
  ## [15.11.4](https://github.com/bigalorm/bigal/compare/v15.11.3...v15.11.4) (2026-03-12)
2
12
 
3
13
  ## [15.11.3](https://github.com/bigalorm/bigal/compare/v15.11.2...v15.11.3) (2026-03-12)
package/README.md CHANGED
@@ -4,9 +4,10 @@
4
4
  [![node version](https://img.shields.io/node/v/bigal.svg?style=flat)](https://nodejs.org)
5
5
  [![Known Vulnerabilities](https://snyk.io/test/npm/bigal/badge.svg)](https://snyk.io/test/npm/bigal)
6
6
 
7
- A PostgreSQL-optimized, type-safe TypeScript ORM for Node.js. BigAl uses a fluent builder pattern for queries,
8
- decorator-based models, and immutable query state. Built exclusively for Postgres — queries are tuned for
9
- Postgres performance with native support for JSONB, DISTINCT ON, subquery joins, and ON CONFLICT upserts.
7
+ A PostgreSQL-optimized, type-safe TypeScript ORM for Node.js. BigAl uses a fluent builder
8
+ pattern for queries, function-based schema definitions with PostgreSQL-native column builders,
9
+ and immutable query state. Built exclusively for Postgres with native support for JSONB,
10
+ DISTINCT ON, subquery joins, ON CONFLICT upserts, and pgvector.
10
11
 
11
12
  ## Install
12
13
 
@@ -27,49 +28,62 @@ npm install pg
27
28
  npm install @neondatabase/serverless
28
29
  ```
29
30
 
31
+ Requires Node.js >= 22.
32
+
30
33
  ## Quick Start
31
34
 
32
35
  ```ts
33
- import { column, primaryColumn, table, Entity, initialize, Repository } from 'bigal';
36
+ import { initialize, defineTable as table, serial, text, integer, belongsTo, hasMany, createdAt, updatedAt } from 'bigal';
37
+ import type { Repository } from 'bigal';
34
38
  import { Pool } from 'postgres-pool';
35
39
 
36
- @table({ name: 'products' })
37
- class Product extends Entity {
38
- @primaryColumn({ type: 'integer' })
39
- public id!: number;
40
-
41
- @column({ type: 'string', required: true })
42
- public name!: string;
43
-
44
- @column({ type: 'integer', required: true, name: 'price_cents' })
45
- public priceCents!: number;
46
- }
47
-
40
+ // Define models with PostgreSQL-native column builders
41
+ // Column names auto-derive from property keys (priceCents -> price_cents)
42
+ const Product = table('products', {
43
+ id: serial().primaryKey(),
44
+ name: text().notNull(),
45
+ priceCents: integer().notNull(),
46
+ store: belongsTo('Store'),
47
+ createdAt: createdAt(),
48
+ updatedAt: updatedAt(),
49
+ });
50
+
51
+ const Store = table('stores', {
52
+ id: serial().primaryKey(),
53
+ name: text(),
54
+ products: hasMany('Product').via('store'),
55
+ });
56
+
57
+ // Initialize with typed destructuring -- no type assertions needed
48
58
  const pool = new Pool('postgres://localhost/mydb');
49
- const repos = initialize({ models: [Product], pool });
50
- const productRepository = repos.Product as Repository<Product>;
59
+ const { Product, Store } = initialize({
60
+ pool,
61
+ models: { Product, Store },
62
+ });
51
63
 
52
- // Fluent queries just await the chain
53
- const products = await productRepository
54
- .find()
64
+ // Fluent queries -- just await the chain
65
+ const products = await Product.find()
55
66
  .where({ priceCents: { '>=': 1000 }, name: { contains: 'widget' } })
56
67
  .sort('name asc')
57
68
  .limit(10);
58
69
 
59
70
  // Upserts with ON CONFLICT
60
- await productRepository.create({ name: 'Widget', sku: 'WDG-001', priceCents: 999 }, { onConflict: { action: 'merge', targets: ['sku'], merge: ['priceCents'] } });
71
+ await Product.create({ name: 'Widget', priceCents: 999, store: 1 }, { onConflict: { action: 'merge', targets: ['name'], merge: ['priceCents'] } });
72
+
73
+ // Inspect generated SQL without executing
74
+ const { sql, params } = Product.find().where({ name: 'Widget' }).toSQL();
61
75
  ```
62
76
 
63
77
  ## Documentation
64
78
 
65
79
  Full documentation is available at **[bigalorm.github.io/bigal](https://bigalorm.github.io/bigal/)**.
66
80
 
67
- - [Getting Started](https://bigalorm.github.io/bigal/getting-started) install, first model, first query
68
- - [Models](https://bigalorm.github.io/bigal/guide/models) decorators, column options, relationships
69
- - [Querying](https://bigalorm.github.io/bigal/guide/querying) operators, pagination, JSONB, DISTINCT ON
70
- - [CRUD Operations](https://bigalorm.github.io/bigal/guide/crud-operations) create, update, destroy, upserts
71
- - [Subqueries & Joins](https://bigalorm.github.io/bigal/guide/subqueries-and-joins) subquery builder, aggregates
72
- - [API Reference](https://bigalorm.github.io/bigal/reference/api) all exports and method signatures
81
+ - [Getting Started](https://bigalorm.github.io/bigal/getting-started) -- install, first model, first query
82
+ - [Models](https://bigalorm.github.io/bigal/guide/models) -- table definitions, column types, relationships
83
+ - [Querying](https://bigalorm.github.io/bigal/guide/querying) -- operators, pagination, JSONB, DISTINCT ON
84
+ - [CRUD Operations](https://bigalorm.github.io/bigal/guide/crud-operations) -- create, update, destroy, upserts
85
+ - [Subqueries & Joins](https://bigalorm.github.io/bigal/guide/subqueries-and-joins) -- subquery builder, aggregates
86
+ - [API Reference](https://bigalorm.github.io/bigal/reference/api) -- all exports and method signatures
73
87
 
74
88
  ## Machine-Readable Documentation
75
89
 
@@ -91,7 +105,7 @@ npx skills add bigalorm/bigal
91
105
  ## Compatibility
92
106
 
93
107
  - [PostgreSQL](http://www.postgresql.org/) 14 or above
94
- - Node.js 20.11.0 or above
108
+ - Node.js 22 or above
95
109
 
96
110
  ## License
97
111