pqb 0.18.19 → 0.18.20
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 +42 -10
- package/dist/index.js +48 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4371,17 +4371,33 @@ declare class Update {
|
|
|
4371
4371
|
updateOrThrow<T extends Query>(this: T, arg: UpdateArg<T>): UpdateResult<T>;
|
|
4372
4372
|
_updateOrThrow<T extends Query>(this: T, arg: UpdateArg<T>): UpdateResult<T>;
|
|
4373
4373
|
/**
|
|
4374
|
-
* Increments a column
|
|
4374
|
+
* Increments a column by `1`, returns a count of updated records by default.
|
|
4375
4375
|
*
|
|
4376
4376
|
* ```ts
|
|
4377
|
-
*
|
|
4378
|
-
*
|
|
4379
|
-
* .
|
|
4377
|
+
* const updatedCount = await db.table
|
|
4378
|
+
* .where(...conditions)
|
|
4379
|
+
* .increment('numericColumn');
|
|
4380
|
+
* ```
|
|
4381
|
+
*
|
|
4382
|
+
* When using `find` or `get` it will throw `NotFoundError` when no records found.
|
|
4383
|
+
*
|
|
4384
|
+
* ```ts
|
|
4385
|
+
* // throws when not found
|
|
4386
|
+
* const updatedCount = await db.table.find(1).increment('numericColumn');
|
|
4387
|
+
*
|
|
4388
|
+
* // also throws when not found
|
|
4389
|
+
* const updatedCount2 = await db.table
|
|
4380
4390
|
* .where(...conditions)
|
|
4391
|
+
* .get('columnName')
|
|
4381
4392
|
* .increment('numericColumn');
|
|
4393
|
+
* ```
|
|
4382
4394
|
*
|
|
4395
|
+
* Provide an object to increment multiple columns with different values.
|
|
4396
|
+
* Use `select` to specify columns to return.
|
|
4397
|
+
*
|
|
4398
|
+
* ```ts
|
|
4383
4399
|
* // increment someColumn by 5 and otherColumn by 10, return updated records
|
|
4384
|
-
* const
|
|
4400
|
+
* const result = await db.table
|
|
4385
4401
|
* .selectAll()
|
|
4386
4402
|
* .where(...conditions)
|
|
4387
4403
|
* .increment({
|
|
@@ -4395,17 +4411,33 @@ declare class Update {
|
|
|
4395
4411
|
increment<T extends Query>(this: T, data: ChangeCountArg<T>): UpdateResult<T>;
|
|
4396
4412
|
_increment<T extends Query>(this: T, data: ChangeCountArg<T>): UpdateResult<T>;
|
|
4397
4413
|
/**
|
|
4398
|
-
* Decrements a column
|
|
4414
|
+
* Decrements a column by `1`, returns a count of updated records by default.
|
|
4399
4415
|
*
|
|
4400
4416
|
* ```ts
|
|
4401
|
-
*
|
|
4402
|
-
*
|
|
4403
|
-
* .
|
|
4417
|
+
* const updatedCount = await db.table
|
|
4418
|
+
* .where(...conditions)
|
|
4419
|
+
* .decrement('numericColumn');
|
|
4420
|
+
* ```
|
|
4421
|
+
*
|
|
4422
|
+
* When using `find` or `get` it will throw `NotFoundError` when no records found.
|
|
4423
|
+
*
|
|
4424
|
+
* ```ts
|
|
4425
|
+
* // throws when not found
|
|
4426
|
+
* const updatedCount = await db.table.find(1).decrement('numericColumn');
|
|
4427
|
+
*
|
|
4428
|
+
* // also throws when not found
|
|
4429
|
+
* const updatedCount2 = await db.table
|
|
4404
4430
|
* .where(...conditions)
|
|
4431
|
+
* .get('columnName')
|
|
4405
4432
|
* .decrement('numericColumn');
|
|
4433
|
+
* ```
|
|
4406
4434
|
*
|
|
4435
|
+
* Provide an object to decrement multiple columns with different values.
|
|
4436
|
+
* Use `select` to specify columns to return.
|
|
4437
|
+
*
|
|
4438
|
+
* ```ts
|
|
4407
4439
|
* // decrement someColumn by 5 and otherColumn by 10, return updated records
|
|
4408
|
-
* const
|
|
4440
|
+
* const result = await db.table
|
|
4409
4441
|
* .selectAll()
|
|
4410
4442
|
* .where(...conditions)
|
|
4411
4443
|
* .decrement({
|
package/dist/index.js
CHANGED
|
@@ -8283,6 +8283,12 @@ var __spreadValues$3 = (a, b) => {
|
|
|
8283
8283
|
};
|
|
8284
8284
|
const applyCountChange = (self, op, data) => {
|
|
8285
8285
|
self.q.type = "update";
|
|
8286
|
+
if (!self.q.select) {
|
|
8287
|
+
if (self.q.returnType === "oneOrThrow" || self.q.returnType === "valueOrThrow") {
|
|
8288
|
+
self.q.throwOnNotFound = true;
|
|
8289
|
+
}
|
|
8290
|
+
self.q.returnType = "rowCount";
|
|
8291
|
+
}
|
|
8286
8292
|
let map;
|
|
8287
8293
|
if (typeof data === "object") {
|
|
8288
8294
|
map = {};
|
|
@@ -8600,17 +8606,33 @@ class Update {
|
|
|
8600
8606
|
return this._update(arg);
|
|
8601
8607
|
}
|
|
8602
8608
|
/**
|
|
8603
|
-
* Increments a column
|
|
8609
|
+
* Increments a column by `1`, returns a count of updated records by default.
|
|
8604
8610
|
*
|
|
8605
8611
|
* ```ts
|
|
8606
|
-
*
|
|
8607
|
-
* const result = await db.table
|
|
8608
|
-
* .selectAll()
|
|
8612
|
+
* const updatedCount = await db.table
|
|
8609
8613
|
* .where(...conditions)
|
|
8610
8614
|
* .increment('numericColumn');
|
|
8615
|
+
* ```
|
|
8611
8616
|
*
|
|
8617
|
+
* When using `find` or `get` it will throw `NotFoundError` when no records found.
|
|
8618
|
+
*
|
|
8619
|
+
* ```ts
|
|
8620
|
+
* // throws when not found
|
|
8621
|
+
* const updatedCount = await db.table.find(1).increment('numericColumn');
|
|
8622
|
+
*
|
|
8623
|
+
* // also throws when not found
|
|
8624
|
+
* const updatedCount2 = await db.table
|
|
8625
|
+
* .where(...conditions)
|
|
8626
|
+
* .get('columnName')
|
|
8627
|
+
* .increment('numericColumn');
|
|
8628
|
+
* ```
|
|
8629
|
+
*
|
|
8630
|
+
* Provide an object to increment multiple columns with different values.
|
|
8631
|
+
* Use `select` to specify columns to return.
|
|
8632
|
+
*
|
|
8633
|
+
* ```ts
|
|
8612
8634
|
* // increment someColumn by 5 and otherColumn by 10, return updated records
|
|
8613
|
-
* const
|
|
8635
|
+
* const result = await db.table
|
|
8614
8636
|
* .selectAll()
|
|
8615
8637
|
* .where(...conditions)
|
|
8616
8638
|
* .increment({
|
|
@@ -8628,17 +8650,33 @@ class Update {
|
|
|
8628
8650
|
return applyCountChange(this, "+", data);
|
|
8629
8651
|
}
|
|
8630
8652
|
/**
|
|
8631
|
-
* Decrements a column
|
|
8653
|
+
* Decrements a column by `1`, returns a count of updated records by default.
|
|
8632
8654
|
*
|
|
8633
8655
|
* ```ts
|
|
8634
|
-
*
|
|
8635
|
-
* const result = await db.table
|
|
8636
|
-
* .selectAll()
|
|
8656
|
+
* const updatedCount = await db.table
|
|
8637
8657
|
* .where(...conditions)
|
|
8638
8658
|
* .decrement('numericColumn');
|
|
8659
|
+
* ```
|
|
8660
|
+
*
|
|
8661
|
+
* When using `find` or `get` it will throw `NotFoundError` when no records found.
|
|
8662
|
+
*
|
|
8663
|
+
* ```ts
|
|
8664
|
+
* // throws when not found
|
|
8665
|
+
* const updatedCount = await db.table.find(1).decrement('numericColumn');
|
|
8639
8666
|
*
|
|
8667
|
+
* // also throws when not found
|
|
8668
|
+
* const updatedCount2 = await db.table
|
|
8669
|
+
* .where(...conditions)
|
|
8670
|
+
* .get('columnName')
|
|
8671
|
+
* .decrement('numericColumn');
|
|
8672
|
+
* ```
|
|
8673
|
+
*
|
|
8674
|
+
* Provide an object to decrement multiple columns with different values.
|
|
8675
|
+
* Use `select` to specify columns to return.
|
|
8676
|
+
*
|
|
8677
|
+
* ```ts
|
|
8640
8678
|
* // decrement someColumn by 5 and otherColumn by 10, return updated records
|
|
8641
|
-
* const
|
|
8679
|
+
* const result = await db.table
|
|
8642
8680
|
* .selectAll()
|
|
8643
8681
|
* .where(...conditions)
|
|
8644
8682
|
* .decrement({
|