bigal 13.0.5 → 13.0.7
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 +8 -0
- package/dist/index.cjs +22 -5
- package/dist/index.d.cts +6 -1
- package/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.mjs +22 -5
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -92,6 +92,7 @@ class ColumnCollectionMetadata extends ColumnBaseMetadata {
|
|
|
92
92
|
_throughFn;
|
|
93
93
|
/**
|
|
94
94
|
* Type of the items in the collection
|
|
95
|
+
* @returns Name of collection
|
|
95
96
|
*/
|
|
96
97
|
get collection() {
|
|
97
98
|
if (this._collectionString) {
|
|
@@ -109,6 +110,7 @@ class ColumnCollectionMetadata extends ColumnBaseMetadata {
|
|
|
109
110
|
via;
|
|
110
111
|
/**
|
|
111
112
|
* Name of the junction table for multi-multi associations
|
|
113
|
+
* @returns Name of junction table
|
|
112
114
|
*/
|
|
113
115
|
get through() {
|
|
114
116
|
if (this._throughString) {
|
|
@@ -167,6 +169,7 @@ class ColumnModelMetadata extends ColumnBaseMetadata {
|
|
|
167
169
|
_modelFn;
|
|
168
170
|
/**
|
|
169
171
|
* Name of the model represented by this column id
|
|
172
|
+
* @returns Name of model
|
|
170
173
|
*/
|
|
171
174
|
get model() {
|
|
172
175
|
if (this._modelString) {
|
|
@@ -1331,6 +1334,7 @@ class ReadonlyRepository {
|
|
|
1331
1334
|
* @param {string[]} [args.select] - Array of model property names to return from the query.
|
|
1332
1335
|
* @param {object} [args.where] - Object representing the where query
|
|
1333
1336
|
* @param {string|object} [args.sort] - Property name(s) to sort by
|
|
1337
|
+
* @returns Database record or null
|
|
1334
1338
|
*/
|
|
1335
1339
|
findOne(args = {}) {
|
|
1336
1340
|
const { stack } = new Error(`${this.model.name}.findOne()`);
|
|
@@ -1374,6 +1378,7 @@ class ReadonlyRepository {
|
|
|
1374
1378
|
/**
|
|
1375
1379
|
* Filters the query
|
|
1376
1380
|
* @param {object} value - Object representing the where query
|
|
1381
|
+
* @returns Query instance
|
|
1377
1382
|
*/
|
|
1378
1383
|
where(value) {
|
|
1379
1384
|
where = value;
|
|
@@ -1388,6 +1393,7 @@ class ReadonlyRepository {
|
|
|
1388
1393
|
* @param {string|object} [options.sort] - Property name(s) to sort by
|
|
1389
1394
|
* @param {string|number} [options.skip] - Number of records to skip
|
|
1390
1395
|
* @param {string|number} [options.limit] - Number of results to return
|
|
1396
|
+
* @returns Query instance
|
|
1391
1397
|
*/
|
|
1392
1398
|
populate(propertyName, options) {
|
|
1393
1399
|
if (select && !select.has(propertyName)) {
|
|
@@ -1411,6 +1417,7 @@ class ReadonlyRepository {
|
|
|
1411
1417
|
/**
|
|
1412
1418
|
* Sorts the query
|
|
1413
1419
|
* @param {string|object} [value]
|
|
1420
|
+
* @returns Query instance
|
|
1414
1421
|
*/
|
|
1415
1422
|
sort(value) {
|
|
1416
1423
|
if (value) {
|
|
@@ -1478,6 +1485,7 @@ ${stack ?? ""}`;
|
|
|
1478
1485
|
* @param {string|object} [args.sort] - Property name(s) to sort by
|
|
1479
1486
|
* @param {string|number} [args.skip] - Number of records to skip
|
|
1480
1487
|
* @param {string|number} [args.limit] - Number of results to return
|
|
1488
|
+
* @returns Database records
|
|
1481
1489
|
*/
|
|
1482
1490
|
find(args = {}) {
|
|
1483
1491
|
const { stack } = new Error(`${this.model.name}.find()`);
|
|
@@ -1530,6 +1538,7 @@ ${stack ?? ""}`;
|
|
|
1530
1538
|
/**
|
|
1531
1539
|
* Filters the query
|
|
1532
1540
|
* @param {object} value - Object representing the where query
|
|
1541
|
+
* @returns Query instance
|
|
1533
1542
|
*/
|
|
1534
1543
|
where(value) {
|
|
1535
1544
|
where = value;
|
|
@@ -1544,6 +1553,7 @@ ${stack ?? ""}`;
|
|
|
1544
1553
|
* @param {string|object} [options.sort] - Property name(s) to sort by
|
|
1545
1554
|
* @param {string|number} [options.skip] - Number of records to skip
|
|
1546
1555
|
* @param {string|number} [options.limit] - Number of results to return
|
|
1556
|
+
* @returns Query instance
|
|
1547
1557
|
*/
|
|
1548
1558
|
populate(propertyName, options) {
|
|
1549
1559
|
if (select && !select.has(propertyName)) {
|
|
@@ -1567,6 +1577,7 @@ ${stack ?? ""}`;
|
|
|
1567
1577
|
/**
|
|
1568
1578
|
* Sorts the query
|
|
1569
1579
|
* @param {string|string[]|object} [value]
|
|
1580
|
+
* @returns Query instance
|
|
1570
1581
|
*/
|
|
1571
1582
|
sort(value) {
|
|
1572
1583
|
if (value) {
|
|
@@ -1577,6 +1588,7 @@ ${stack ?? ""}`;
|
|
|
1577
1588
|
/**
|
|
1578
1589
|
* Limits results returned by the query
|
|
1579
1590
|
* @param {number} value
|
|
1591
|
+
* @returns Query instance
|
|
1580
1592
|
*/
|
|
1581
1593
|
limit(value) {
|
|
1582
1594
|
limit = value;
|
|
@@ -1585,6 +1597,7 @@ ${stack ?? ""}`;
|
|
|
1585
1597
|
/**
|
|
1586
1598
|
* Skips records returned by the query
|
|
1587
1599
|
* @param {number} value
|
|
1600
|
+
* @returns Query instance
|
|
1588
1601
|
*/
|
|
1589
1602
|
skip(value) {
|
|
1590
1603
|
skip = value;
|
|
@@ -1596,8 +1609,9 @@ ${stack ?? ""}`;
|
|
|
1596
1609
|
},
|
|
1597
1610
|
/**
|
|
1598
1611
|
* Pages records returned by the query
|
|
1599
|
-
* @param {number} [page
|
|
1600
|
-
* @param {number} [limit
|
|
1612
|
+
* @param {number} [page] - Page to return - Starts at 1
|
|
1613
|
+
* @param {number} [limit] - Number of records to return
|
|
1614
|
+
* @returns Query instance
|
|
1601
1615
|
*/
|
|
1602
1616
|
paginate({ page = 1, limit: paginateLimit = 10 }) {
|
|
1603
1617
|
const safePage = Math.max(page, 1);
|
|
@@ -1671,6 +1685,7 @@ ${stack ?? ""}`;
|
|
|
1671
1685
|
/**
|
|
1672
1686
|
* Filters the query
|
|
1673
1687
|
* @param {object} value - Object representing the where query
|
|
1688
|
+
* @returns Count result
|
|
1674
1689
|
*/
|
|
1675
1690
|
where(value) {
|
|
1676
1691
|
where = value;
|
|
@@ -1968,7 +1983,7 @@ class Repository extends ReadonlyRepository {
|
|
|
1968
1983
|
* Creates an object using the specified values
|
|
1969
1984
|
* @param {object|object[]} values - Values to insert as a new object. If an array is specified, multiple rows will be inserted
|
|
1970
1985
|
* @param {object} [options]
|
|
1971
|
-
* @param {boolean} [options.returnRecords
|
|
1986
|
+
* @param {boolean} [options.returnRecords] - Determines if inserted records should be returned
|
|
1972
1987
|
* @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
|
|
1973
1988
|
* @param {object} [options.onConflict] - Options to handle conflicts due to a unique constraint or exclusion constraint error during insert
|
|
1974
1989
|
* @returns {object|object[]|void} Return value from the db
|
|
@@ -2022,7 +2037,7 @@ class Repository extends ReadonlyRepository {
|
|
|
2022
2037
|
* @param {object} where - Object representing the where query
|
|
2023
2038
|
* @param {object} values - Values to update
|
|
2024
2039
|
* @param {object} [options]
|
|
2025
|
-
* @param {boolean} [options.returnRecords
|
|
2040
|
+
* @param {boolean} [options.returnRecords] - Determines if inserted records should be returned
|
|
2026
2041
|
* @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
|
|
2027
2042
|
* @returns {object[]|void} Return values from the db or `true` if returnRecords=false
|
|
2028
2043
|
*/
|
|
@@ -2063,7 +2078,7 @@ class Repository extends ReadonlyRepository {
|
|
|
2063
2078
|
* Destroys object(s) matching the where query
|
|
2064
2079
|
* @param {object} where - Object representing the where query
|
|
2065
2080
|
* @param {object} [options]
|
|
2066
|
-
* @param {boolean} [options.returnRecords
|
|
2081
|
+
* @param {boolean} [options.returnRecords] - Determines if inserted records should be returned
|
|
2067
2082
|
* @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
|
|
2068
2083
|
* @returns {object[]|void} `void` or records affected if returnRecords=true
|
|
2069
2084
|
*/
|
|
@@ -2079,6 +2094,7 @@ class Repository extends ReadonlyRepository {
|
|
|
2079
2094
|
/**
|
|
2080
2095
|
* Filters the query
|
|
2081
2096
|
* @param {object} value - Object representing the where query
|
|
2097
|
+
* @returns Query instance
|
|
2082
2098
|
*/
|
|
2083
2099
|
where(value) {
|
|
2084
2100
|
where = value;
|
|
@@ -2457,6 +2473,7 @@ function initialize({ models, pool, readonlyPool = pool, connections = {}, expos
|
|
|
2457
2473
|
throw new Error(`Unable to find @table() on ${model.name}`);
|
|
2458
2474
|
}
|
|
2459
2475
|
modelMetadataByModelName[model.name] = new ModelMetadata({
|
|
2476
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-spread
|
|
2460
2477
|
...modelMetadata,
|
|
2461
2478
|
name: model.name,
|
|
2462
2479
|
type: model
|
package/dist/index.d.cts
CHANGED
|
@@ -223,6 +223,7 @@ declare class ColumnCollectionMetadata extends ColumnBaseMetadata {
|
|
|
223
223
|
private _throughFn?;
|
|
224
224
|
/**
|
|
225
225
|
* Type of the items in the collection
|
|
226
|
+
* @returns Name of collection
|
|
226
227
|
*/
|
|
227
228
|
get collection(): string;
|
|
228
229
|
/**
|
|
@@ -231,6 +232,7 @@ declare class ColumnCollectionMetadata extends ColumnBaseMetadata {
|
|
|
231
232
|
via: string;
|
|
232
233
|
/**
|
|
233
234
|
* Name of the junction table for multi-multi associations
|
|
235
|
+
* @returns Name of junction table
|
|
234
236
|
*/
|
|
235
237
|
get through(): string | undefined;
|
|
236
238
|
constructor({ target, //
|
|
@@ -248,6 +250,7 @@ declare class ColumnModelMetadata extends ColumnBaseMetadata {
|
|
|
248
250
|
private _modelFn?;
|
|
249
251
|
/**
|
|
250
252
|
* Name of the model represented by this column id
|
|
253
|
+
* @returns Name of model
|
|
251
254
|
*/
|
|
252
255
|
get model(): string;
|
|
253
256
|
constructor({ target, //
|
|
@@ -439,7 +442,7 @@ interface DestroyResult<TEntity extends Entity, TReturn> extends PromiseLike<TRe
|
|
|
439
442
|
where(args: WhereQuery<TEntity>): DestroyResult<TEntity, TReturn>;
|
|
440
443
|
}
|
|
441
444
|
|
|
442
|
-
type SortString<T extends Entity> = `${string & keyof OmitFunctions<OmitEntityCollections<T>>} ASC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} asc` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} DESC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} desc` |
|
|
445
|
+
type SortString<T extends Entity> = `${string & keyof OmitFunctions<OmitEntityCollections<T>>} ASC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} asc` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} DESC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} desc` | (string & keyof OmitFunctions<OmitEntityCollections<T>>);
|
|
443
446
|
type ValidateMultipleSorts<T extends Entity, TNextSortPart extends string, TPreviouslyValidatedSortString extends string, TSortString extends string> = TNextSortPart extends `, ${SortString<T>}${infer TRestSortPart}` ? TRestSortPart extends '' ? TSortString : ValidateMultipleSorts<T, TRestSortPart, TNextSortPart extends `${infer TValidatedSortPart}${TRestSortPart}` ? `${TPreviouslyValidatedSortString}${TValidatedSortPart}` : never, TSortString> : `${TPreviouslyValidatedSortString}, ${SortString<T>}`;
|
|
444
447
|
type MultipleSortString<T extends Entity, TSortString extends string = string> = TSortString extends `${SortString<T>}${infer TRestSortPart}` ? TRestSortPart extends '' ? TSortString : ValidateMultipleSorts<T, TRestSortPart, TSortString extends `${infer TPreviouslyValidatedSortString}${TRestSortPart}` ? TPreviouslyValidatedSortString : never, TSortString> : SortString<T>;
|
|
445
448
|
type SortObjectValue = -1 | 'asc' | 'desc' | 1;
|
|
@@ -679,6 +682,7 @@ declare class ReadonlyRepository<T extends Entity> implements IReadonlyRepositor
|
|
|
679
682
|
* @param {string[]} [args.select] - Array of model property names to return from the query.
|
|
680
683
|
* @param {object} [args.where] - Object representing the where query
|
|
681
684
|
* @param {string|object} [args.sort] - Property name(s) to sort by
|
|
685
|
+
* @returns Database record or null
|
|
682
686
|
*/
|
|
683
687
|
findOne<K extends string & keyof T, TReturn = QueryResult<Pick<T, K | keyof PickFunctions<T> | 'id'>>>(args?: FindOneArgs<T, K> | WhereQuery<T>): FindOneResult<T, TReturn>;
|
|
684
688
|
/**
|
|
@@ -689,6 +693,7 @@ declare class ReadonlyRepository<T extends Entity> implements IReadonlyRepositor
|
|
|
689
693
|
* @param {string|object} [args.sort] - Property name(s) to sort by
|
|
690
694
|
* @param {string|number} [args.skip] - Number of records to skip
|
|
691
695
|
* @param {string|number} [args.limit] - Number of results to return
|
|
696
|
+
* @returns Database records
|
|
692
697
|
*/
|
|
693
698
|
find<K extends string & keyof T, TReturn = QueryResult<Pick<T, K | keyof PickFunctions<T> | 'id'>>>(args?: FindArgs<T, K> | WhereQuery<T>): FindResult<T, TReturn>;
|
|
694
699
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -223,6 +223,7 @@ declare class ColumnCollectionMetadata extends ColumnBaseMetadata {
|
|
|
223
223
|
private _throughFn?;
|
|
224
224
|
/**
|
|
225
225
|
* Type of the items in the collection
|
|
226
|
+
* @returns Name of collection
|
|
226
227
|
*/
|
|
227
228
|
get collection(): string;
|
|
228
229
|
/**
|
|
@@ -231,6 +232,7 @@ declare class ColumnCollectionMetadata extends ColumnBaseMetadata {
|
|
|
231
232
|
via: string;
|
|
232
233
|
/**
|
|
233
234
|
* Name of the junction table for multi-multi associations
|
|
235
|
+
* @returns Name of junction table
|
|
234
236
|
*/
|
|
235
237
|
get through(): string | undefined;
|
|
236
238
|
constructor({ target, //
|
|
@@ -248,6 +250,7 @@ declare class ColumnModelMetadata extends ColumnBaseMetadata {
|
|
|
248
250
|
private _modelFn?;
|
|
249
251
|
/**
|
|
250
252
|
* Name of the model represented by this column id
|
|
253
|
+
* @returns Name of model
|
|
251
254
|
*/
|
|
252
255
|
get model(): string;
|
|
253
256
|
constructor({ target, //
|
|
@@ -439,7 +442,7 @@ interface DestroyResult<TEntity extends Entity, TReturn> extends PromiseLike<TRe
|
|
|
439
442
|
where(args: WhereQuery<TEntity>): DestroyResult<TEntity, TReturn>;
|
|
440
443
|
}
|
|
441
444
|
|
|
442
|
-
type SortString<T extends Entity> = `${string & keyof OmitFunctions<OmitEntityCollections<T>>} ASC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} asc` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} DESC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} desc` |
|
|
445
|
+
type SortString<T extends Entity> = `${string & keyof OmitFunctions<OmitEntityCollections<T>>} ASC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} asc` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} DESC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} desc` | (string & keyof OmitFunctions<OmitEntityCollections<T>>);
|
|
443
446
|
type ValidateMultipleSorts<T extends Entity, TNextSortPart extends string, TPreviouslyValidatedSortString extends string, TSortString extends string> = TNextSortPart extends `, ${SortString<T>}${infer TRestSortPart}` ? TRestSortPart extends '' ? TSortString : ValidateMultipleSorts<T, TRestSortPart, TNextSortPart extends `${infer TValidatedSortPart}${TRestSortPart}` ? `${TPreviouslyValidatedSortString}${TValidatedSortPart}` : never, TSortString> : `${TPreviouslyValidatedSortString}, ${SortString<T>}`;
|
|
444
447
|
type MultipleSortString<T extends Entity, TSortString extends string = string> = TSortString extends `${SortString<T>}${infer TRestSortPart}` ? TRestSortPart extends '' ? TSortString : ValidateMultipleSorts<T, TRestSortPart, TSortString extends `${infer TPreviouslyValidatedSortString}${TRestSortPart}` ? TPreviouslyValidatedSortString : never, TSortString> : SortString<T>;
|
|
445
448
|
type SortObjectValue = -1 | 'asc' | 'desc' | 1;
|
|
@@ -679,6 +682,7 @@ declare class ReadonlyRepository<T extends Entity> implements IReadonlyRepositor
|
|
|
679
682
|
* @param {string[]} [args.select] - Array of model property names to return from the query.
|
|
680
683
|
* @param {object} [args.where] - Object representing the where query
|
|
681
684
|
* @param {string|object} [args.sort] - Property name(s) to sort by
|
|
685
|
+
* @returns Database record or null
|
|
682
686
|
*/
|
|
683
687
|
findOne<K extends string & keyof T, TReturn = QueryResult<Pick<T, K | keyof PickFunctions<T> | 'id'>>>(args?: FindOneArgs<T, K> | WhereQuery<T>): FindOneResult<T, TReturn>;
|
|
684
688
|
/**
|
|
@@ -689,6 +693,7 @@ declare class ReadonlyRepository<T extends Entity> implements IReadonlyRepositor
|
|
|
689
693
|
* @param {string|object} [args.sort] - Property name(s) to sort by
|
|
690
694
|
* @param {string|number} [args.skip] - Number of records to skip
|
|
691
695
|
* @param {string|number} [args.limit] - Number of results to return
|
|
696
|
+
* @returns Database records
|
|
692
697
|
*/
|
|
693
698
|
find<K extends string & keyof T, TReturn = QueryResult<Pick<T, K | keyof PickFunctions<T> | 'id'>>>(args?: FindArgs<T, K> | WhereQuery<T>): FindResult<T, TReturn>;
|
|
694
699
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -223,6 +223,7 @@ declare class ColumnCollectionMetadata extends ColumnBaseMetadata {
|
|
|
223
223
|
private _throughFn?;
|
|
224
224
|
/**
|
|
225
225
|
* Type of the items in the collection
|
|
226
|
+
* @returns Name of collection
|
|
226
227
|
*/
|
|
227
228
|
get collection(): string;
|
|
228
229
|
/**
|
|
@@ -231,6 +232,7 @@ declare class ColumnCollectionMetadata extends ColumnBaseMetadata {
|
|
|
231
232
|
via: string;
|
|
232
233
|
/**
|
|
233
234
|
* Name of the junction table for multi-multi associations
|
|
235
|
+
* @returns Name of junction table
|
|
234
236
|
*/
|
|
235
237
|
get through(): string | undefined;
|
|
236
238
|
constructor({ target, //
|
|
@@ -248,6 +250,7 @@ declare class ColumnModelMetadata extends ColumnBaseMetadata {
|
|
|
248
250
|
private _modelFn?;
|
|
249
251
|
/**
|
|
250
252
|
* Name of the model represented by this column id
|
|
253
|
+
* @returns Name of model
|
|
251
254
|
*/
|
|
252
255
|
get model(): string;
|
|
253
256
|
constructor({ target, //
|
|
@@ -439,7 +442,7 @@ interface DestroyResult<TEntity extends Entity, TReturn> extends PromiseLike<TRe
|
|
|
439
442
|
where(args: WhereQuery<TEntity>): DestroyResult<TEntity, TReturn>;
|
|
440
443
|
}
|
|
441
444
|
|
|
442
|
-
type SortString<T extends Entity> = `${string & keyof OmitFunctions<OmitEntityCollections<T>>} ASC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} asc` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} DESC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} desc` |
|
|
445
|
+
type SortString<T extends Entity> = `${string & keyof OmitFunctions<OmitEntityCollections<T>>} ASC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} asc` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} DESC` | `${string & keyof OmitFunctions<OmitEntityCollections<T>>} desc` | (string & keyof OmitFunctions<OmitEntityCollections<T>>);
|
|
443
446
|
type ValidateMultipleSorts<T extends Entity, TNextSortPart extends string, TPreviouslyValidatedSortString extends string, TSortString extends string> = TNextSortPart extends `, ${SortString<T>}${infer TRestSortPart}` ? TRestSortPart extends '' ? TSortString : ValidateMultipleSorts<T, TRestSortPart, TNextSortPart extends `${infer TValidatedSortPart}${TRestSortPart}` ? `${TPreviouslyValidatedSortString}${TValidatedSortPart}` : never, TSortString> : `${TPreviouslyValidatedSortString}, ${SortString<T>}`;
|
|
444
447
|
type MultipleSortString<T extends Entity, TSortString extends string = string> = TSortString extends `${SortString<T>}${infer TRestSortPart}` ? TRestSortPart extends '' ? TSortString : ValidateMultipleSorts<T, TRestSortPart, TSortString extends `${infer TPreviouslyValidatedSortString}${TRestSortPart}` ? TPreviouslyValidatedSortString : never, TSortString> : SortString<T>;
|
|
445
448
|
type SortObjectValue = -1 | 'asc' | 'desc' | 1;
|
|
@@ -679,6 +682,7 @@ declare class ReadonlyRepository<T extends Entity> implements IReadonlyRepositor
|
|
|
679
682
|
* @param {string[]} [args.select] - Array of model property names to return from the query.
|
|
680
683
|
* @param {object} [args.where] - Object representing the where query
|
|
681
684
|
* @param {string|object} [args.sort] - Property name(s) to sort by
|
|
685
|
+
* @returns Database record or null
|
|
682
686
|
*/
|
|
683
687
|
findOne<K extends string & keyof T, TReturn = QueryResult<Pick<T, K | keyof PickFunctions<T> | 'id'>>>(args?: FindOneArgs<T, K> | WhereQuery<T>): FindOneResult<T, TReturn>;
|
|
684
688
|
/**
|
|
@@ -689,6 +693,7 @@ declare class ReadonlyRepository<T extends Entity> implements IReadonlyRepositor
|
|
|
689
693
|
* @param {string|object} [args.sort] - Property name(s) to sort by
|
|
690
694
|
* @param {string|number} [args.skip] - Number of records to skip
|
|
691
695
|
* @param {string|number} [args.limit] - Number of results to return
|
|
696
|
+
* @returns Database records
|
|
692
697
|
*/
|
|
693
698
|
find<K extends string & keyof T, TReturn = QueryResult<Pick<T, K | keyof PickFunctions<T> | 'id'>>>(args?: FindArgs<T, K> | WhereQuery<T>): FindResult<T, TReturn>;
|
|
694
699
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -86,6 +86,7 @@ class ColumnCollectionMetadata extends ColumnBaseMetadata {
|
|
|
86
86
|
_throughFn;
|
|
87
87
|
/**
|
|
88
88
|
* Type of the items in the collection
|
|
89
|
+
* @returns Name of collection
|
|
89
90
|
*/
|
|
90
91
|
get collection() {
|
|
91
92
|
if (this._collectionString) {
|
|
@@ -103,6 +104,7 @@ class ColumnCollectionMetadata extends ColumnBaseMetadata {
|
|
|
103
104
|
via;
|
|
104
105
|
/**
|
|
105
106
|
* Name of the junction table for multi-multi associations
|
|
107
|
+
* @returns Name of junction table
|
|
106
108
|
*/
|
|
107
109
|
get through() {
|
|
108
110
|
if (this._throughString) {
|
|
@@ -161,6 +163,7 @@ class ColumnModelMetadata extends ColumnBaseMetadata {
|
|
|
161
163
|
_modelFn;
|
|
162
164
|
/**
|
|
163
165
|
* Name of the model represented by this column id
|
|
166
|
+
* @returns Name of model
|
|
164
167
|
*/
|
|
165
168
|
get model() {
|
|
166
169
|
if (this._modelString) {
|
|
@@ -1325,6 +1328,7 @@ class ReadonlyRepository {
|
|
|
1325
1328
|
* @param {string[]} [args.select] - Array of model property names to return from the query.
|
|
1326
1329
|
* @param {object} [args.where] - Object representing the where query
|
|
1327
1330
|
* @param {string|object} [args.sort] - Property name(s) to sort by
|
|
1331
|
+
* @returns Database record or null
|
|
1328
1332
|
*/
|
|
1329
1333
|
findOne(args = {}) {
|
|
1330
1334
|
const { stack } = new Error(`${this.model.name}.findOne()`);
|
|
@@ -1368,6 +1372,7 @@ class ReadonlyRepository {
|
|
|
1368
1372
|
/**
|
|
1369
1373
|
* Filters the query
|
|
1370
1374
|
* @param {object} value - Object representing the where query
|
|
1375
|
+
* @returns Query instance
|
|
1371
1376
|
*/
|
|
1372
1377
|
where(value) {
|
|
1373
1378
|
where = value;
|
|
@@ -1382,6 +1387,7 @@ class ReadonlyRepository {
|
|
|
1382
1387
|
* @param {string|object} [options.sort] - Property name(s) to sort by
|
|
1383
1388
|
* @param {string|number} [options.skip] - Number of records to skip
|
|
1384
1389
|
* @param {string|number} [options.limit] - Number of results to return
|
|
1390
|
+
* @returns Query instance
|
|
1385
1391
|
*/
|
|
1386
1392
|
populate(propertyName, options) {
|
|
1387
1393
|
if (select && !select.has(propertyName)) {
|
|
@@ -1405,6 +1411,7 @@ class ReadonlyRepository {
|
|
|
1405
1411
|
/**
|
|
1406
1412
|
* Sorts the query
|
|
1407
1413
|
* @param {string|object} [value]
|
|
1414
|
+
* @returns Query instance
|
|
1408
1415
|
*/
|
|
1409
1416
|
sort(value) {
|
|
1410
1417
|
if (value) {
|
|
@@ -1472,6 +1479,7 @@ ${stack ?? ""}`;
|
|
|
1472
1479
|
* @param {string|object} [args.sort] - Property name(s) to sort by
|
|
1473
1480
|
* @param {string|number} [args.skip] - Number of records to skip
|
|
1474
1481
|
* @param {string|number} [args.limit] - Number of results to return
|
|
1482
|
+
* @returns Database records
|
|
1475
1483
|
*/
|
|
1476
1484
|
find(args = {}) {
|
|
1477
1485
|
const { stack } = new Error(`${this.model.name}.find()`);
|
|
@@ -1524,6 +1532,7 @@ ${stack ?? ""}`;
|
|
|
1524
1532
|
/**
|
|
1525
1533
|
* Filters the query
|
|
1526
1534
|
* @param {object} value - Object representing the where query
|
|
1535
|
+
* @returns Query instance
|
|
1527
1536
|
*/
|
|
1528
1537
|
where(value) {
|
|
1529
1538
|
where = value;
|
|
@@ -1538,6 +1547,7 @@ ${stack ?? ""}`;
|
|
|
1538
1547
|
* @param {string|object} [options.sort] - Property name(s) to sort by
|
|
1539
1548
|
* @param {string|number} [options.skip] - Number of records to skip
|
|
1540
1549
|
* @param {string|number} [options.limit] - Number of results to return
|
|
1550
|
+
* @returns Query instance
|
|
1541
1551
|
*/
|
|
1542
1552
|
populate(propertyName, options) {
|
|
1543
1553
|
if (select && !select.has(propertyName)) {
|
|
@@ -1561,6 +1571,7 @@ ${stack ?? ""}`;
|
|
|
1561
1571
|
/**
|
|
1562
1572
|
* Sorts the query
|
|
1563
1573
|
* @param {string|string[]|object} [value]
|
|
1574
|
+
* @returns Query instance
|
|
1564
1575
|
*/
|
|
1565
1576
|
sort(value) {
|
|
1566
1577
|
if (value) {
|
|
@@ -1571,6 +1582,7 @@ ${stack ?? ""}`;
|
|
|
1571
1582
|
/**
|
|
1572
1583
|
* Limits results returned by the query
|
|
1573
1584
|
* @param {number} value
|
|
1585
|
+
* @returns Query instance
|
|
1574
1586
|
*/
|
|
1575
1587
|
limit(value) {
|
|
1576
1588
|
limit = value;
|
|
@@ -1579,6 +1591,7 @@ ${stack ?? ""}`;
|
|
|
1579
1591
|
/**
|
|
1580
1592
|
* Skips records returned by the query
|
|
1581
1593
|
* @param {number} value
|
|
1594
|
+
* @returns Query instance
|
|
1582
1595
|
*/
|
|
1583
1596
|
skip(value) {
|
|
1584
1597
|
skip = value;
|
|
@@ -1590,8 +1603,9 @@ ${stack ?? ""}`;
|
|
|
1590
1603
|
},
|
|
1591
1604
|
/**
|
|
1592
1605
|
* Pages records returned by the query
|
|
1593
|
-
* @param {number} [page
|
|
1594
|
-
* @param {number} [limit
|
|
1606
|
+
* @param {number} [page] - Page to return - Starts at 1
|
|
1607
|
+
* @param {number} [limit] - Number of records to return
|
|
1608
|
+
* @returns Query instance
|
|
1595
1609
|
*/
|
|
1596
1610
|
paginate({ page = 1, limit: paginateLimit = 10 }) {
|
|
1597
1611
|
const safePage = Math.max(page, 1);
|
|
@@ -1665,6 +1679,7 @@ ${stack ?? ""}`;
|
|
|
1665
1679
|
/**
|
|
1666
1680
|
* Filters the query
|
|
1667
1681
|
* @param {object} value - Object representing the where query
|
|
1682
|
+
* @returns Count result
|
|
1668
1683
|
*/
|
|
1669
1684
|
where(value) {
|
|
1670
1685
|
where = value;
|
|
@@ -1962,7 +1977,7 @@ class Repository extends ReadonlyRepository {
|
|
|
1962
1977
|
* Creates an object using the specified values
|
|
1963
1978
|
* @param {object|object[]} values - Values to insert as a new object. If an array is specified, multiple rows will be inserted
|
|
1964
1979
|
* @param {object} [options]
|
|
1965
|
-
* @param {boolean} [options.returnRecords
|
|
1980
|
+
* @param {boolean} [options.returnRecords] - Determines if inserted records should be returned
|
|
1966
1981
|
* @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
|
|
1967
1982
|
* @param {object} [options.onConflict] - Options to handle conflicts due to a unique constraint or exclusion constraint error during insert
|
|
1968
1983
|
* @returns {object|object[]|void} Return value from the db
|
|
@@ -2016,7 +2031,7 @@ class Repository extends ReadonlyRepository {
|
|
|
2016
2031
|
* @param {object} where - Object representing the where query
|
|
2017
2032
|
* @param {object} values - Values to update
|
|
2018
2033
|
* @param {object} [options]
|
|
2019
|
-
* @param {boolean} [options.returnRecords
|
|
2034
|
+
* @param {boolean} [options.returnRecords] - Determines if inserted records should be returned
|
|
2020
2035
|
* @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
|
|
2021
2036
|
* @returns {object[]|void} Return values from the db or `true` if returnRecords=false
|
|
2022
2037
|
*/
|
|
@@ -2057,7 +2072,7 @@ class Repository extends ReadonlyRepository {
|
|
|
2057
2072
|
* Destroys object(s) matching the where query
|
|
2058
2073
|
* @param {object} where - Object representing the where query
|
|
2059
2074
|
* @param {object} [options]
|
|
2060
|
-
* @param {boolean} [options.returnRecords
|
|
2075
|
+
* @param {boolean} [options.returnRecords] - Determines if inserted records should be returned
|
|
2061
2076
|
* @param {string[]} [options.returnSelect] - Array of model property names to return from the query.
|
|
2062
2077
|
* @returns {object[]|void} `void` or records affected if returnRecords=true
|
|
2063
2078
|
*/
|
|
@@ -2073,6 +2088,7 @@ class Repository extends ReadonlyRepository {
|
|
|
2073
2088
|
/**
|
|
2074
2089
|
* Filters the query
|
|
2075
2090
|
* @param {object} value - Object representing the where query
|
|
2091
|
+
* @returns Query instance
|
|
2076
2092
|
*/
|
|
2077
2093
|
where(value) {
|
|
2078
2094
|
where = value;
|
|
@@ -2451,6 +2467,7 @@ function initialize({ models, pool, readonlyPool = pool, connections = {}, expos
|
|
|
2451
2467
|
throw new Error(`Unable to find @table() on ${model.name}`);
|
|
2452
2468
|
}
|
|
2453
2469
|
modelMetadataByModelName[model.name] = new ModelMetadata({
|
|
2470
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-spread
|
|
2454
2471
|
...modelMetadata,
|
|
2455
2472
|
name: model.name,
|
|
2456
2473
|
type: model
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bigal",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.7",
|
|
4
4
|
"description": "A fast and lightweight orm for postgres and node.js, written in typescript.",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -33,32 +33,32 @@
|
|
|
33
33
|
"node": ">=18"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@types/pg": "^8.11.
|
|
36
|
+
"@types/pg": "^8.11.11",
|
|
37
37
|
"lodash": "^4.17.21",
|
|
38
|
-
"pg": "^8.13.
|
|
39
|
-
"postgres-pool": "^
|
|
38
|
+
"pg": "^8.13.3",
|
|
39
|
+
"postgres-pool": "^10.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@faker-js/faker": "^9.
|
|
43
|
-
"@types/chai": "^5.0
|
|
44
|
-
"@types/lodash": "^4.17.
|
|
42
|
+
"@faker-js/faker": "^9.6.0",
|
|
43
|
+
"@types/chai": "^5.2.0",
|
|
44
|
+
"@types/lodash": "^4.17.16",
|
|
45
45
|
"@types/mocha": "10.0.10",
|
|
46
46
|
"@types/node": ">=22",
|
|
47
|
-
"chai": "^5.
|
|
48
|
-
"eslint": "^9.
|
|
49
|
-
"eslint-config-decent": "^2.
|
|
47
|
+
"chai": "^5.2.0",
|
|
48
|
+
"eslint": "^9.22.0",
|
|
49
|
+
"eslint-config-decent": "^2.6.1",
|
|
50
50
|
"husky": "^9.1.7",
|
|
51
|
-
"lint-staged": "^15.
|
|
52
|
-
"markdownlint-cli": "^0.
|
|
53
|
-
"mocha": "^11.0
|
|
51
|
+
"lint-staged": "^15.4.3",
|
|
52
|
+
"markdownlint-cli": "^0.44.0",
|
|
53
|
+
"mocha": "^11.1.0",
|
|
54
54
|
"npm-run-all": "^4.1.5",
|
|
55
55
|
"pinst": "^3.0.0",
|
|
56
|
-
"prettier": "^3.
|
|
56
|
+
"prettier": "^3.5.3",
|
|
57
57
|
"strict-event-emitter-types": "^2.0.0",
|
|
58
58
|
"ts-mockito": "^2.6.1",
|
|
59
59
|
"ts-node": "^10.9.2",
|
|
60
|
-
"typescript": "^5.
|
|
61
|
-
"unbuild": "^3.0
|
|
60
|
+
"typescript": "^5.8.2",
|
|
61
|
+
"unbuild": "^3.5.0"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "unbuild",
|