pqb 0.40.2 → 0.40.3
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/dist/index.d.ts +24 -14
- package/dist/index.js +15 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -6567,7 +6567,7 @@ declare class QueryUpsertOrCreate {
|
|
|
6567
6567
|
*
|
|
6568
6568
|
* ```ts
|
|
6569
6569
|
* await User.selectAll()
|
|
6570
|
-
* .
|
|
6570
|
+
* .findBy({ email: 'some@email.com' })
|
|
6571
6571
|
* .upsert({
|
|
6572
6572
|
* data: {
|
|
6573
6573
|
* // update record's name
|
|
@@ -6581,7 +6581,7 @@ declare class QueryUpsertOrCreate {
|
|
|
6581
6581
|
*
|
|
6582
6582
|
* // the same as above but using `update` and `create`
|
|
6583
6583
|
* await User.selectAll()
|
|
6584
|
-
* .
|
|
6584
|
+
* .findBy({ email: 'some@email.com' })
|
|
6585
6585
|
* .upsert({
|
|
6586
6586
|
* update: {
|
|
6587
6587
|
* name: 'updated user',
|
|
@@ -6598,7 +6598,7 @@ declare class QueryUpsertOrCreate {
|
|
|
6598
6598
|
*
|
|
6599
6599
|
* ```ts
|
|
6600
6600
|
* await User.selectAll()
|
|
6601
|
-
* .
|
|
6601
|
+
* .findBy({ email: 'some@email.com' })
|
|
6602
6602
|
* .upsert({
|
|
6603
6603
|
* update: {
|
|
6604
6604
|
* name: 'updated user',
|
|
@@ -6611,7 +6611,7 @@ declare class QueryUpsertOrCreate {
|
|
|
6611
6611
|
*
|
|
6612
6612
|
* // the same as above using `data`
|
|
6613
6613
|
* await User.selectAll()
|
|
6614
|
-
* .
|
|
6614
|
+
* .findBy({ email: 'some@email.com' })
|
|
6615
6615
|
* .upsert({
|
|
6616
6616
|
* data: {
|
|
6617
6617
|
* name: 'updated user',
|
|
@@ -6628,7 +6628,7 @@ declare class QueryUpsertOrCreate {
|
|
|
6628
6628
|
*
|
|
6629
6629
|
* ```ts
|
|
6630
6630
|
* const user = await User.selectAll()
|
|
6631
|
-
* .
|
|
6631
|
+
* .findBy({ email: 'some@email.com' })
|
|
6632
6632
|
* .upsert({
|
|
6633
6633
|
* data: {
|
|
6634
6634
|
* name: 'updated user',
|
|
@@ -6661,17 +6661,19 @@ declare class QueryUpsertOrCreate {
|
|
|
6661
6661
|
* By default, it is not returning columns, place `get`, `select`, or `selectAll` before `orCreate` to specify returning columns.
|
|
6662
6662
|
*
|
|
6663
6663
|
* ```ts
|
|
6664
|
-
* const user = await User.selectAll()
|
|
6665
|
-
* email: 'some@email.com'
|
|
6666
|
-
*
|
|
6667
|
-
*
|
|
6664
|
+
* const user = await User.selectAll()
|
|
6665
|
+
* .findBy({ email: 'some@email.com' })
|
|
6666
|
+
* .orCreate({
|
|
6667
|
+
* email: 'some@email.com',
|
|
6668
|
+
* name: 'created user',
|
|
6669
|
+
* });
|
|
6668
6670
|
* ```
|
|
6669
6671
|
*
|
|
6670
6672
|
* The data may be returned from a function, it won't be called if the record was found:
|
|
6671
6673
|
*
|
|
6672
6674
|
* ```ts
|
|
6673
6675
|
* const user = await User.selectAll()
|
|
6674
|
-
* .
|
|
6676
|
+
* .findBy({ email: 'some@email.com' })
|
|
6675
6677
|
* .orCreate(() => ({
|
|
6676
6678
|
* email: 'some@email.com',
|
|
6677
6679
|
* name: 'created user',
|
|
@@ -6748,11 +6750,11 @@ declare class QueryMap {
|
|
|
6748
6750
|
/**
|
|
6749
6751
|
* Use `map` to transform individual records of a query result.
|
|
6750
6752
|
*
|
|
6751
|
-
*
|
|
6753
|
+
* Use `map` to transform individual records of a query result. If the query returns multiple, `map` function going to transform records one by one.
|
|
6752
6754
|
*
|
|
6753
|
-
* For
|
|
6755
|
+
* For an optional query result (`findOptional`, `getOptional`, etc.), `map` is **not** called for empty results.
|
|
6754
6756
|
*
|
|
6755
|
-
*
|
|
6757
|
+
* For transforming the result of a query as a whole, consider using {@link Query.transform} instead.
|
|
6756
6758
|
*
|
|
6757
6759
|
* ```ts
|
|
6758
6760
|
* // add a `titleLength` to every post
|
|
@@ -6785,10 +6787,18 @@ declare class QueryMap {
|
|
|
6785
6787
|
*
|
|
6786
6788
|
* @param fn - function to transform an individual record
|
|
6787
6789
|
*/
|
|
6788
|
-
map<T extends Query, Result
|
|
6790
|
+
map<T extends Query, Result>(this: T, fn: (input: T['returnType'] extends undefined | 'all' | 'pluck' ? T['then'] extends QueryThen<(infer Data)[]> ? Data : never : T['then'] extends QueryThen<infer Data | undefined> ? Data : never) => Result): Result extends RecordUnknown ? {
|
|
6789
6791
|
[K in keyof T]: K extends 'result' ? {
|
|
6790
6792
|
[K in keyof Result]: QueryColumn<Result[K]>;
|
|
6791
6793
|
} : K extends 'then' ? QueryThen<T['returnType'] extends undefined | 'all' ? Result[] : Result> : T[K];
|
|
6794
|
+
} : {
|
|
6795
|
+
[K in keyof T]: K extends 'returnType' ? T['returnType'] extends undefined | 'all' | 'pluck' ? 'pluck' : T['returnType'] extends 'one' ? 'value' : 'valueOrThrow' : K extends 'result' ? T['returnType'] extends undefined | 'all' | 'pluck' ? {
|
|
6796
|
+
pluck: QueryColumn<Result>;
|
|
6797
|
+
} : T['returnType'] extends 'one' | 'value' ? {
|
|
6798
|
+
value: QueryColumn<Result | undefined>;
|
|
6799
|
+
} : {
|
|
6800
|
+
value: QueryColumn<Result>;
|
|
6801
|
+
} : K extends 'then' ? QueryThen<T['returnType'] extends undefined | 'all' | 'pluck' ? Result[] : Result> : T[K];
|
|
6792
6802
|
};
|
|
6793
6803
|
}
|
|
6794
6804
|
|
package/dist/index.js
CHANGED
|
@@ -11159,7 +11159,7 @@ class QueryUpsertOrCreate {
|
|
|
11159
11159
|
*
|
|
11160
11160
|
* ```ts
|
|
11161
11161
|
* await User.selectAll()
|
|
11162
|
-
* .
|
|
11162
|
+
* .findBy({ email: 'some@email.com' })
|
|
11163
11163
|
* .upsert({
|
|
11164
11164
|
* data: {
|
|
11165
11165
|
* // update record's name
|
|
@@ -11173,7 +11173,7 @@ class QueryUpsertOrCreate {
|
|
|
11173
11173
|
*
|
|
11174
11174
|
* // the same as above but using `update` and `create`
|
|
11175
11175
|
* await User.selectAll()
|
|
11176
|
-
* .
|
|
11176
|
+
* .findBy({ email: 'some@email.com' })
|
|
11177
11177
|
* .upsert({
|
|
11178
11178
|
* update: {
|
|
11179
11179
|
* name: 'updated user',
|
|
@@ -11190,7 +11190,7 @@ class QueryUpsertOrCreate {
|
|
|
11190
11190
|
*
|
|
11191
11191
|
* ```ts
|
|
11192
11192
|
* await User.selectAll()
|
|
11193
|
-
* .
|
|
11193
|
+
* .findBy({ email: 'some@email.com' })
|
|
11194
11194
|
* .upsert({
|
|
11195
11195
|
* update: {
|
|
11196
11196
|
* name: 'updated user',
|
|
@@ -11203,7 +11203,7 @@ class QueryUpsertOrCreate {
|
|
|
11203
11203
|
*
|
|
11204
11204
|
* // the same as above using `data`
|
|
11205
11205
|
* await User.selectAll()
|
|
11206
|
-
* .
|
|
11206
|
+
* .findBy({ email: 'some@email.com' })
|
|
11207
11207
|
* .upsert({
|
|
11208
11208
|
* data: {
|
|
11209
11209
|
* name: 'updated user',
|
|
@@ -11220,7 +11220,7 @@ class QueryUpsertOrCreate {
|
|
|
11220
11220
|
*
|
|
11221
11221
|
* ```ts
|
|
11222
11222
|
* const user = await User.selectAll()
|
|
11223
|
-
* .
|
|
11223
|
+
* .findBy({ email: 'some@email.com' })
|
|
11224
11224
|
* .upsert({
|
|
11225
11225
|
* data: {
|
|
11226
11226
|
* name: 'updated user',
|
|
@@ -11260,17 +11260,19 @@ class QueryUpsertOrCreate {
|
|
|
11260
11260
|
* By default, it is not returning columns, place `get`, `select`, or `selectAll` before `orCreate` to specify returning columns.
|
|
11261
11261
|
*
|
|
11262
11262
|
* ```ts
|
|
11263
|
-
* const user = await User.selectAll()
|
|
11264
|
-
* email: 'some@email.com'
|
|
11265
|
-
*
|
|
11266
|
-
*
|
|
11263
|
+
* const user = await User.selectAll()
|
|
11264
|
+
* .findBy({ email: 'some@email.com' })
|
|
11265
|
+
* .orCreate({
|
|
11266
|
+
* email: 'some@email.com',
|
|
11267
|
+
* name: 'created user',
|
|
11268
|
+
* });
|
|
11267
11269
|
* ```
|
|
11268
11270
|
*
|
|
11269
11271
|
* The data may be returned from a function, it won't be called if the record was found:
|
|
11270
11272
|
*
|
|
11271
11273
|
* ```ts
|
|
11272
11274
|
* const user = await User.selectAll()
|
|
11273
|
-
* .
|
|
11275
|
+
* .findBy({ email: 'some@email.com' })
|
|
11274
11276
|
* .orCreate(() => ({
|
|
11275
11277
|
* email: 'some@email.com',
|
|
11276
11278
|
* name: 'created user',
|
|
@@ -11371,11 +11373,11 @@ class QueryMap {
|
|
|
11371
11373
|
/**
|
|
11372
11374
|
* Use `map` to transform individual records of a query result.
|
|
11373
11375
|
*
|
|
11374
|
-
*
|
|
11376
|
+
* Use `map` to transform individual records of a query result. If the query returns multiple, `map` function going to transform records one by one.
|
|
11375
11377
|
*
|
|
11376
|
-
* For
|
|
11378
|
+
* For an optional query result (`findOptional`, `getOptional`, etc.), `map` is **not** called for empty results.
|
|
11377
11379
|
*
|
|
11378
|
-
*
|
|
11380
|
+
* For transforming the result of a query as a whole, consider using {@link Query.transform} instead.
|
|
11379
11381
|
*
|
|
11380
11382
|
* ```ts
|
|
11381
11383
|
* // add a `titleLength` to every post
|