@taylordb/query-builder 0.10.1 → 0.10.2

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.
Files changed (2) hide show
  1. package/README.md +32 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -52,6 +52,38 @@ const customers = await qb
52
52
  .execute();
53
53
  ```
54
54
 
55
+ #### Counting Records
56
+
57
+ Use the `count()` method to get the total number of records that match your query. This is useful for pagination, statistics, or checking if records exist.
58
+
59
+ ```typescript
60
+ // Count all users
61
+ const totalUsers = await qb
62
+ .selectFrom('users')
63
+ .count();
64
+
65
+ console.log(`Total users: ${totalUsers}`);
66
+
67
+ // Count with filters
68
+ const activeUsers = await qb
69
+ .selectFrom('users')
70
+ .where('status', '=', 'active')
71
+ .where('age', '>', 18)
72
+ .count();
73
+
74
+ console.log(`Active adult users: ${activeUsers}`);
75
+
76
+ // Count with relations filter
77
+ const usersWithPosts = await qb
78
+ .selectFrom('users')
79
+ .where('posts', 'isNotEmpty')
80
+ .count();
81
+
82
+ console.log(`Users with posts: ${usersWithPosts}`);
83
+ ```
84
+
85
+ **Note**: The `count()` method returns a `Promise<number>` directly (not an array), and it respects all filters, pagination, and sorting you've applied to the query.
86
+
55
87
  ### Inserting Data
56
88
 
57
89
  You can insert data into a table using the `insertInto` method.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taylordb/query-builder",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "description": "A type-safe query builder for TaylorDB",
5
5
  "private": false,
6
6
  "main": "./dist/cjs/index.js",