@taylordb/query-builder 0.16.3 → 0.17.0

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.
@@ -0,0 +1,63 @@
1
+ # Sorting
2
+
3
+ Use `.orderBy()` to control the order of results returned by a select or aggregation query.
4
+
5
+ ## `.orderBy(field, direction?)`
6
+
7
+ | Parameter | Type | Default | Description |
8
+ |-----------|------|---------|-------------|
9
+ | `field` | `keyof Table` | — | The field to sort by. TypeScript will autocomplete valid field names for the table. |
10
+ | `direction` | `'asc' \| 'desc'` | `'asc'` | Sort direction. |
11
+
12
+ ```ts
13
+ const users = await qb
14
+ .selectFrom('users')
15
+ .select(['id', 'name', 'createdAt'])
16
+ .orderBy('name', 'asc')
17
+ .execute();
18
+ ```
19
+
20
+ ## Multiple sort fields
21
+
22
+ Chain `.orderBy()` multiple times. The sorts are applied in the order they are added.
23
+
24
+ ```ts
25
+ const users = await qb
26
+ .selectFrom('users')
27
+ .selectAll()
28
+ .orderBy('role', 'asc')
29
+ .orderBy('name', 'asc')
30
+ .execute();
31
+ // sorted by role ascending, then by name ascending within each role
32
+ ```
33
+
34
+ ## With pagination
35
+
36
+ Sorting composes cleanly with `.limit()`, `.offset()`, and `.paginate()`.
37
+
38
+ ```ts
39
+ const page2 = await qb
40
+ .selectFrom('posts')
41
+ .select(['id', 'title', 'createdAt'])
42
+ .orderBy('createdAt', 'desc')
43
+ .paginate(2, 20)
44
+ .execute();
45
+ ```
46
+
47
+ ## On aggregation queries
48
+
49
+ `.orderBy()` works the same way on `AggregationQueryBuilder`.
50
+
51
+ ```ts
52
+ const stats = await qb
53
+ .aggregateFrom('orders')
54
+ .groupBy('status')
55
+ .metrics({ total: count('id') })
56
+ .orderBy('status', 'asc')
57
+ .execute();
58
+ ```
59
+
60
+ ## Limitations
61
+
62
+ - Sorting is only available on root select queries and aggregation queries. It is not available when configuring a sub-query inside `.with({ ... })`.
63
+ - You cannot sort by a link field directly. Sort by scalar fields on the table.
package/llm.txt ADDED
@@ -0,0 +1,29 @@
1
+ # @taylordb/query-builder — LLM Documentation Index
2
+
3
+ This package is the TypeScript query builder for TaylorDB. It provides a fluent, type-safe API for reading and writing data. Use `createQueryBuilder<TaylorDatabase>(config)` as the entry point — the `TaylorDatabase` type is generated by `@taylordb/cli`.
4
+
5
+ ## Documentation
6
+
7
+ - [Field Types](./docs/field-types.md)
8
+ All column types (`TextColumnType`, `NumberColumnType`, `DateColumnType`, `CheckboxColumnType`, `SingleSelectColumnType`, `MultiSelectColumnType`, `LinkColumnType`, `AttachmentColumnType`, `SearchColumnType`, auto-generated variants). What value each type accepts on insert/update, what is returned on select, and which filter operators are available per type.
9
+
10
+ - [Insert](./docs/insert.md)
11
+ How to create records using `insertInto().values().returning().execute()`. Single and batch inserts, the default return value, how attachment and link fields are handled on insert, and which tables cannot be inserted into.
12
+
13
+ - [File Upload](./docs/file-upload.md)
14
+ How to upload files with `qb.uploadAttachments()`, how to attach the resulting `Attachment` instances to a record on insert or update, how to add/remove individual attachments on update, and how attachment URLs are resolved when reading.
15
+
16
+ - [Current User](./docs/current-user.md)
17
+ How to retrieve the authenticated user's profile with `qb.auth.getUser()`, what it returns, and what is required for it to work.
18
+
19
+ - [Sorting](./docs/sorting.md)
20
+ How to sort results with `.orderBy(field, direction)`, chaining multiple sort fields, using sorting with pagination, and sorting on aggregation queries.
21
+
22
+ - [Conditions](./docs/conditions.md)
23
+ How to filter records with `.where()` and `.orWhere()`. Simple conditions, AND/OR chaining, grouped/nested conditions via callbacks, cross-table filtering on link fields, isEmpty/isNotEmpty, checkbox and date filter values.
24
+
25
+ - [Relationships](./docs/relationships.md)
26
+ How to load linked records with `.with()`. Simple string/array form, object form with sub-query configuration, nesting relationships, and what cannot be loaded (attachments, aggregated counts, relationships inside insert returning).
27
+
28
+ - [Pagination](./docs/pagination.md)
29
+ How to paginate with `.limit()`, `.offset()`, `.paginate(page, limit)`, how to get the total record count with `.count()`, pagination on sub-queries, and pagination on aggregation queries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taylordb/query-builder",
3
- "version": "0.16.3",
3
+ "version": "0.17.0",
4
4
  "description": "A type-safe query builder for TaylorDB",
5
5
  "private": false,
6
6
  "main": "./dist/cjs/index.js",
@@ -14,7 +14,9 @@
14
14
  }
15
15
  },
16
16
  "files": [
17
- "dist"
17
+ "dist",
18
+ "docs",
19
+ "llm.txt"
18
20
  ],
19
21
  "keywords": [
20
22
  "query-builder",
@@ -29,7 +31,7 @@
29
31
  "lodash": "^4.17.21",
30
32
  "socket.io-client": "^4.8.1",
31
33
  "zod": "^4.1.12",
32
- "@taylordb/shared": "0.16.3"
34
+ "@taylordb/shared": "0.17.0"
33
35
  },
34
36
  "devDependencies": {
35
37
  "@types/eventemitter3": "^2.0.4",