pqb 0.18.28 → 0.18.30
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 +34 -15
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -9591,11 +9591,27 @@ class QueryMethods {
|
|
|
9591
9591
|
*
|
|
9592
9592
|
* ```ts
|
|
9593
9593
|
* // Select the category and sum of prices grouped by the category
|
|
9594
|
-
* const results =
|
|
9594
|
+
* const results = db.product
|
|
9595
|
+
* .select('category')
|
|
9595
9596
|
* .selectSum('price', { as: 'sumPrice' })
|
|
9596
9597
|
* .group('category');
|
|
9597
9598
|
* ```
|
|
9598
9599
|
*
|
|
9600
|
+
* Also, it's possible to group by a selected value:
|
|
9601
|
+
*
|
|
9602
|
+
* ```ts
|
|
9603
|
+
* const results = db.product
|
|
9604
|
+
* .select({
|
|
9605
|
+
* month: db.product.sql`extract(month from "createdAt")`.type((t) =>
|
|
9606
|
+
* // month is returned as string, parse it to int
|
|
9607
|
+
* t.string().parse(parseInt),
|
|
9608
|
+
* ),
|
|
9609
|
+
* })
|
|
9610
|
+
* .selectSum('price', { as: 'sumPrice' })
|
|
9611
|
+
* // group by month extracted from "createdAt"
|
|
9612
|
+
* .group('month');
|
|
9613
|
+
* ```
|
|
9614
|
+
*
|
|
9599
9615
|
* @param columns - column names or a raw SQL
|
|
9600
9616
|
*/
|
|
9601
9617
|
group(...columns) {
|