pqb 0.40.2 → 0.40.4
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 +18 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -14
- 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
|
@@ -6383,7 +6383,9 @@ const makeColumnsByType = (schema) => {
|
|
|
6383
6383
|
jsonb: schema.json,
|
|
6384
6384
|
smallserial: t.smallSerial,
|
|
6385
6385
|
serial: t.serial,
|
|
6386
|
-
bigserial: t.bigSerial
|
|
6386
|
+
bigserial: t.bigSerial,
|
|
6387
|
+
// requires citext extension
|
|
6388
|
+
citext: t.citext
|
|
6387
6389
|
};
|
|
6388
6390
|
};
|
|
6389
6391
|
|
|
@@ -11159,7 +11161,7 @@ class QueryUpsertOrCreate {
|
|
|
11159
11161
|
*
|
|
11160
11162
|
* ```ts
|
|
11161
11163
|
* await User.selectAll()
|
|
11162
|
-
* .
|
|
11164
|
+
* .findBy({ email: 'some@email.com' })
|
|
11163
11165
|
* .upsert({
|
|
11164
11166
|
* data: {
|
|
11165
11167
|
* // update record's name
|
|
@@ -11173,7 +11175,7 @@ class QueryUpsertOrCreate {
|
|
|
11173
11175
|
*
|
|
11174
11176
|
* // the same as above but using `update` and `create`
|
|
11175
11177
|
* await User.selectAll()
|
|
11176
|
-
* .
|
|
11178
|
+
* .findBy({ email: 'some@email.com' })
|
|
11177
11179
|
* .upsert({
|
|
11178
11180
|
* update: {
|
|
11179
11181
|
* name: 'updated user',
|
|
@@ -11190,7 +11192,7 @@ class QueryUpsertOrCreate {
|
|
|
11190
11192
|
*
|
|
11191
11193
|
* ```ts
|
|
11192
11194
|
* await User.selectAll()
|
|
11193
|
-
* .
|
|
11195
|
+
* .findBy({ email: 'some@email.com' })
|
|
11194
11196
|
* .upsert({
|
|
11195
11197
|
* update: {
|
|
11196
11198
|
* name: 'updated user',
|
|
@@ -11203,7 +11205,7 @@ class QueryUpsertOrCreate {
|
|
|
11203
11205
|
*
|
|
11204
11206
|
* // the same as above using `data`
|
|
11205
11207
|
* await User.selectAll()
|
|
11206
|
-
* .
|
|
11208
|
+
* .findBy({ email: 'some@email.com' })
|
|
11207
11209
|
* .upsert({
|
|
11208
11210
|
* data: {
|
|
11209
11211
|
* name: 'updated user',
|
|
@@ -11220,7 +11222,7 @@ class QueryUpsertOrCreate {
|
|
|
11220
11222
|
*
|
|
11221
11223
|
* ```ts
|
|
11222
11224
|
* const user = await User.selectAll()
|
|
11223
|
-
* .
|
|
11225
|
+
* .findBy({ email: 'some@email.com' })
|
|
11224
11226
|
* .upsert({
|
|
11225
11227
|
* data: {
|
|
11226
11228
|
* name: 'updated user',
|
|
@@ -11260,17 +11262,19 @@ class QueryUpsertOrCreate {
|
|
|
11260
11262
|
* By default, it is not returning columns, place `get`, `select`, or `selectAll` before `orCreate` to specify returning columns.
|
|
11261
11263
|
*
|
|
11262
11264
|
* ```ts
|
|
11263
|
-
* const user = await User.selectAll()
|
|
11264
|
-
* email: 'some@email.com'
|
|
11265
|
-
*
|
|
11266
|
-
*
|
|
11265
|
+
* const user = await User.selectAll()
|
|
11266
|
+
* .findBy({ email: 'some@email.com' })
|
|
11267
|
+
* .orCreate({
|
|
11268
|
+
* email: 'some@email.com',
|
|
11269
|
+
* name: 'created user',
|
|
11270
|
+
* });
|
|
11267
11271
|
* ```
|
|
11268
11272
|
*
|
|
11269
11273
|
* The data may be returned from a function, it won't be called if the record was found:
|
|
11270
11274
|
*
|
|
11271
11275
|
* ```ts
|
|
11272
11276
|
* const user = await User.selectAll()
|
|
11273
|
-
* .
|
|
11277
|
+
* .findBy({ email: 'some@email.com' })
|
|
11274
11278
|
* .orCreate(() => ({
|
|
11275
11279
|
* email: 'some@email.com',
|
|
11276
11280
|
* name: 'created user',
|
|
@@ -11371,11 +11375,11 @@ class QueryMap {
|
|
|
11371
11375
|
/**
|
|
11372
11376
|
* Use `map` to transform individual records of a query result.
|
|
11373
11377
|
*
|
|
11374
|
-
*
|
|
11378
|
+
* 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
11379
|
*
|
|
11376
|
-
* For
|
|
11380
|
+
* For an optional query result (`findOptional`, `getOptional`, etc.), `map` is **not** called for empty results.
|
|
11377
11381
|
*
|
|
11378
|
-
*
|
|
11382
|
+
* For transforming the result of a query as a whole, consider using {@link Query.transform} instead.
|
|
11379
11383
|
*
|
|
11380
11384
|
* ```ts
|
|
11381
11385
|
* // add a `titleLength` to every post
|