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.mjs CHANGED
@@ -8281,6 +8281,12 @@ var __spreadValues$3 = (a, b) => {
8281
8281
  };
8282
8282
  const applyCountChange = (self, op, data) => {
8283
8283
  self.q.type = "update";
8284
+ if (!self.q.select) {
8285
+ if (self.q.returnType === "oneOrThrow" || self.q.returnType === "valueOrThrow") {
8286
+ self.q.throwOnNotFound = true;
8287
+ }
8288
+ self.q.returnType = "rowCount";
8289
+ }
8284
8290
  let map;
8285
8291
  if (typeof data === "object") {
8286
8292
  map = {};
@@ -8598,17 +8604,33 @@ class Update {
8598
8604
  return this._update(arg);
8599
8605
  }
8600
8606
  /**
8601
- * Increments a column value by the specified amount. Optionally takes `returning` argument.
8607
+ * Increments a column by `1`, returns a count of updated records by default.
8602
8608
  *
8603
8609
  * ```ts
8604
- * // increment numericColumn column by 1, return updated records
8605
- * const result = await db.table
8606
- * .selectAll()
8610
+ * const updatedCount = await db.table
8607
8611
  * .where(...conditions)
8608
8612
  * .increment('numericColumn');
8613
+ * ```
8609
8614
  *
8615
+ * When using `find` or `get` it will throw `NotFoundError` when no records found.
8616
+ *
8617
+ * ```ts
8618
+ * // throws when not found
8619
+ * const updatedCount = await db.table.find(1).increment('numericColumn');
8620
+ *
8621
+ * // also throws when not found
8622
+ * const updatedCount2 = await db.table
8623
+ * .where(...conditions)
8624
+ * .get('columnName')
8625
+ * .increment('numericColumn');
8626
+ * ```
8627
+ *
8628
+ * Provide an object to increment multiple columns with different values.
8629
+ * Use `select` to specify columns to return.
8630
+ *
8631
+ * ```ts
8610
8632
  * // increment someColumn by 5 and otherColumn by 10, return updated records
8611
- * const result2 = await db.table
8633
+ * const result = await db.table
8612
8634
  * .selectAll()
8613
8635
  * .where(...conditions)
8614
8636
  * .increment({
@@ -8626,17 +8648,33 @@ class Update {
8626
8648
  return applyCountChange(this, "+", data);
8627
8649
  }
8628
8650
  /**
8629
- * Decrements a column value by the specified amount. Optionally takes `returning` argument.
8651
+ * Decrements a column by `1`, returns a count of updated records by default.
8630
8652
  *
8631
8653
  * ```ts
8632
- * // decrement numericColumn column by 1, return updated records
8633
- * const result = await db.table
8634
- * .selectAll()
8654
+ * const updatedCount = await db.table
8635
8655
  * .where(...conditions)
8636
8656
  * .decrement('numericColumn');
8657
+ * ```
8658
+ *
8659
+ * When using `find` or `get` it will throw `NotFoundError` when no records found.
8660
+ *
8661
+ * ```ts
8662
+ * // throws when not found
8663
+ * const updatedCount = await db.table.find(1).decrement('numericColumn');
8637
8664
  *
8665
+ * // also throws when not found
8666
+ * const updatedCount2 = await db.table
8667
+ * .where(...conditions)
8668
+ * .get('columnName')
8669
+ * .decrement('numericColumn');
8670
+ * ```
8671
+ *
8672
+ * Provide an object to decrement multiple columns with different values.
8673
+ * Use `select` to specify columns to return.
8674
+ *
8675
+ * ```ts
8638
8676
  * // decrement someColumn by 5 and otherColumn by 10, return updated records
8639
- * const result2 = await db.table
8677
+ * const result = await db.table
8640
8678
  * .selectAll()
8641
8679
  * .where(...conditions)
8642
8680
  * .decrement({