bigal 15.1.0 → 15.2.0
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 +6 -0
- package/README.md +86 -1
- package/dist/index.cjs +398 -76
- package/dist/index.d.cts +89 -35
- package/dist/index.d.mts +89 -35
- package/dist/index.d.ts +89 -35
- package/dist/index.mjs +398 -76
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
# [15.2.0](https://github.com/bigalorm/bigal/compare/v15.1.0...v15.2.0) (2026-01-08)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- Add SQL JOIN support for filtering and sorting by related tables ([#263](https://github.com/bigalorm/bigal/issues/263)) ([e5f1a97](https://github.com/bigalorm/bigal/commit/e5f1a97f524d8e784943d179347dc364a62959e1))
|
|
6
|
+
|
|
1
7
|
# [15.1.0](https://github.com/bigalorm/bigal/compare/v15.0.1...v15.1.0) (2026-01-07)
|
|
2
8
|
|
|
3
9
|
### Features
|
package/README.md
CHANGED
|
@@ -9,7 +9,6 @@ A fast, lightweight ORM for PostgreSQL and Node.js, written in TypeScript.
|
|
|
9
9
|
This ORM does not:
|
|
10
10
|
|
|
11
11
|
- Create or update db schemas for you
|
|
12
|
-
- Handle associations/joins
|
|
13
12
|
- Do much else than basic queries, inserts, updates, and deletes
|
|
14
13
|
|
|
15
14
|
## Compatibility
|
|
@@ -461,6 +460,92 @@ const items = await FooRepository.find()
|
|
|
461
460
|
.paginate(page, pageSize);
|
|
462
461
|
```
|
|
463
462
|
|
|
463
|
+
#### Join related tables
|
|
464
|
+
|
|
465
|
+
Use `join()` for INNER JOIN or `leftJoin()` for LEFT JOIN to filter or sort by related table columns in a single query.
|
|
466
|
+
|
|
467
|
+
```ts
|
|
468
|
+
// INNER JOIN - only returns products that have a store
|
|
469
|
+
const items = await ProductRepository.find()
|
|
470
|
+
.join('store')
|
|
471
|
+
.where({
|
|
472
|
+
store: {
|
|
473
|
+
name: 'Acme',
|
|
474
|
+
},
|
|
475
|
+
});
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
```ts
|
|
479
|
+
// LEFT JOIN - returns all products, even those without a store
|
|
480
|
+
const items = await ProductRepository.find()
|
|
481
|
+
.leftJoin('store')
|
|
482
|
+
.where({
|
|
483
|
+
store: {
|
|
484
|
+
name: 'Acme',
|
|
485
|
+
},
|
|
486
|
+
});
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
#### Join with alias
|
|
490
|
+
|
|
491
|
+
Use an alias when you need to join the same table multiple times or for clarity.
|
|
492
|
+
|
|
493
|
+
```ts
|
|
494
|
+
const items = await ProductRepository.find()
|
|
495
|
+
.join('store', 'primaryStore')
|
|
496
|
+
.where({
|
|
497
|
+
primaryStore: {
|
|
498
|
+
name: 'Acme',
|
|
499
|
+
},
|
|
500
|
+
});
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
#### Join with additional ON constraints
|
|
504
|
+
|
|
505
|
+
Add extra conditions to the JOIN's ON clause using `leftJoin()`.
|
|
506
|
+
|
|
507
|
+
```ts
|
|
508
|
+
const items = await ProductRepository.find()
|
|
509
|
+
.leftJoin('store', 'store', {
|
|
510
|
+
isDeleted: false,
|
|
511
|
+
})
|
|
512
|
+
.where({
|
|
513
|
+
name: {
|
|
514
|
+
like: 'Widget%',
|
|
515
|
+
},
|
|
516
|
+
});
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
#### Sort by joined table columns
|
|
520
|
+
|
|
521
|
+
Use dot notation to sort by columns on joined tables.
|
|
522
|
+
|
|
523
|
+
```ts
|
|
524
|
+
const items = await ProductRepository.find().join('store').sort('store.name asc');
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
#### Combine multiple where conditions
|
|
528
|
+
|
|
529
|
+
Mix regular where conditions with joined table conditions.
|
|
530
|
+
|
|
531
|
+
```ts
|
|
532
|
+
const items = await ProductRepository.find()
|
|
533
|
+
.join('store')
|
|
534
|
+
.where({
|
|
535
|
+
name: {
|
|
536
|
+
like: 'Widget%',
|
|
537
|
+
},
|
|
538
|
+
store: {
|
|
539
|
+
name: {
|
|
540
|
+
like: ['Acme', 'foo'],
|
|
541
|
+
},
|
|
542
|
+
},
|
|
543
|
+
});
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
> Note: `join()` and `populate()` serve different purposes. Use `join()` when you need to filter or sort by related
|
|
547
|
+
> table columns in SQL. Use `populate()` when you want to fetch the full related object(s) as nested data in results.
|
|
548
|
+
|
|
464
549
|
---
|
|
465
550
|
|
|
466
551
|
### `.count()` - Get the number of records matching the where criteria
|