kitcn 0.31.0 → 0.32.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.
@@ -1,4 +1,4 @@
1
- import { $t as OrmLifecycleChange, A as CreateDatabaseOptions, Ar as $Type, B as getUniqueIndexes, Ct as OrderByClause, F as CascadeMode, Ft as ExtractTablesFromSchema, Gn as Columns, Gt as TablesRelationalConfig, Ht as RelationsBuilderConfigValue, I as DeleteMode, Kn as OrmRuntimeDefaults, L as SerializedFilterExpression, Mr as ColumnBuilder, Mt as VectorSearchProvider, N as OrmReader, Nr as ColumnBuilderBaseConfig, Or as SystemFieldAliases, P as OrmWriter, Pt as AnyRelationsBuilderConfig, Qn as OrmSchemaTriggers, R as getChecks, U as EdgeMetadata, Un as ConvexColumnBuilder, Ur as entityKind, Ut as RelationsConfigWithSchema, Vn as ConvexTextBuilderInitial, Wt as TableRelationalConfig, Xt as ConvexTable, Yn as OrmSchemaExtensionTriggers, Zn as OrmSchemaRelations, Zt as ConvexTableWithColumns, an as RlsPolicy, dt as InferInsertModel, kr as SystemFields, pt as InferSelectModel, qn as OrmSchemaExtensionRelations, r as OrmCapability, rr as FilterExpression$1, x as MigrationSet, z as getForeignKeys, zr as HasDefault, zt as RelationsBuilder } from "./capabilities-DPB-JKlm.js";
1
+ import { $t as OrmLifecycleChange, A as CreateDatabaseOptions, Ar as $Type, B as getUniqueIndexes, Ct as OrderByClause, F as CascadeMode, Ft as ExtractTablesFromSchema, Gn as Columns, Gt as TablesRelationalConfig, Ht as RelationsBuilderConfigValue, I as DeleteMode, Kn as OrmRuntimeDefaults, L as SerializedFilterExpression, Mr as ColumnBuilder, Mt as VectorSearchProvider, N as OrmReader, Nr as ColumnBuilderBaseConfig, Or as SystemFieldAliases, P as OrmWriter, Pt as AnyRelationsBuilderConfig, Qn as OrmSchemaTriggers, R as getChecks, U as EdgeMetadata, Un as ConvexColumnBuilder, Ur as entityKind, Ut as RelationsConfigWithSchema, Vn as ConvexTextBuilderInitial, Wt as TableRelationalConfig, Xt as ConvexTable, Yn as OrmSchemaExtensionTriggers, Zn as OrmSchemaRelations, Zt as ConvexTableWithColumns, an as RlsPolicy, dt as InferInsertModel, kr as SystemFields, pt as InferSelectModel, qn as OrmSchemaExtensionRelations, r as OrmCapability, rr as FilterExpression$1, x as MigrationSet, z as getForeignKeys, zr as HasDefault, zt as RelationsBuilder } from "./capabilities-CD-Ij91k.js";
2
2
  import * as convex_values0 from "convex/values";
3
3
  import { GenericId, Validator, Value } from "convex/values";
4
4
  import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchedulableFunctionReference, Scheduler, SchemaDefinition, internalActionGeneric, internalMutationGeneric, internalQueryGeneric } from "convex/server";
@@ -111,6 +111,15 @@ declare const migrationStorageTables: {
111
111
  fieldName: "direction";
112
112
  };
113
113
  };
114
+ cursor: ConvexTextBuilderInitial<""> & {
115
+ _: {
116
+ tableName: "migration_state";
117
+ };
118
+ } & {
119
+ _: {
120
+ fieldName: "cursor";
121
+ };
122
+ };
114
123
  migrationId: ConvexTextBuilderInitial<""> & {
115
124
  _: {
116
125
  notNull: true;
@@ -159,15 +168,6 @@ declare const migrationStorageTables: {
159
168
  fieldName: "runId";
160
169
  };
161
170
  };
162
- cursor: ConvexTextBuilderInitial<""> & {
163
- _: {
164
- tableName: "migration_state";
165
- };
166
- } & {
167
- _: {
168
- fieldName: "cursor";
169
- };
170
- };
171
171
  processed: ConvexNumberBuilderInitial<""> & {
172
172
  _: {
173
173
  notNull: true;
@@ -1011,7 +1011,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1011
1011
  readonly aggregate_bucket: ConvexTableWithColumns<{
1012
1012
  name: "aggregate_bucket";
1013
1013
  columns: {
1014
- count: ConvexNumberBuilderInitial<""> & {
1014
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1015
1015
  _: {
1016
1016
  notNull: true;
1017
1017
  };
@@ -1021,10 +1021,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1021
1021
  };
1022
1022
  } & {
1023
1023
  _: {
1024
- fieldName: "count";
1024
+ fieldName: "updatedAt";
1025
1025
  };
1026
1026
  };
1027
- updatedAt: ConvexNumberBuilderInitial<""> & {
1027
+ tableKey: ConvexTextBuilderInitial<""> & {
1028
1028
  _: {
1029
1029
  notNull: true;
1030
1030
  };
@@ -1034,7 +1034,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1034
1034
  };
1035
1035
  } & {
1036
1036
  _: {
1037
- fieldName: "updatedAt";
1037
+ fieldName: "tableKey";
1038
1038
  };
1039
1039
  };
1040
1040
  indexName: ConvexTextBuilderInitial<""> & {
@@ -1050,7 +1050,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1050
1050
  fieldName: "indexName";
1051
1051
  };
1052
1052
  };
1053
- tableKey: ConvexTextBuilderInitial<""> & {
1053
+ keyHash: ConvexTextBuilderInitial<""> & {
1054
1054
  _: {
1055
1055
  notNull: true;
1056
1056
  };
@@ -1060,10 +1060,14 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1060
1060
  };
1061
1061
  } & {
1062
1062
  _: {
1063
- fieldName: "tableKey";
1063
+ fieldName: "keyHash";
1064
1064
  };
1065
1065
  };
1066
- keyHash: ConvexTextBuilderInitial<""> & {
1066
+ keyParts: ConvexCustomBuilderInitial<"", convex_values0.VArray<any[], convex_values0.Validator<any, "required", any>, "required">> & {
1067
+ _: {
1068
+ $type: convex_values0.Value[];
1069
+ };
1070
+ } & {
1067
1071
  _: {
1068
1072
  notNull: true;
1069
1073
  };
@@ -1073,14 +1077,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1073
1077
  };
1074
1078
  } & {
1075
1079
  _: {
1076
- fieldName: "keyHash";
1080
+ fieldName: "keyParts";
1077
1081
  };
1078
1082
  };
1079
- keyParts: ConvexCustomBuilderInitial<"", convex_values0.VArray<any[], convex_values0.Validator<any, "required", any>, "required">> & {
1080
- _: {
1081
- $type: convex_values0.Value[];
1082
- };
1083
- } & {
1083
+ count: ConvexNumberBuilderInitial<""> & {
1084
1084
  _: {
1085
1085
  notNull: true;
1086
1086
  };
@@ -1090,7 +1090,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1090
1090
  };
1091
1091
  } & {
1092
1092
  _: {
1093
- fieldName: "keyParts";
1093
+ fieldName: "count";
1094
1094
  };
1095
1095
  };
1096
1096
  sumValues: ConvexCustomBuilderInitial<"", ConvexValidatorLike> & {
@@ -1136,7 +1136,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1136
1136
  readonly aggregate_member: ConvexTableWithColumns<{
1137
1137
  name: "aggregate_member";
1138
1138
  columns: {
1139
- updatedAt: ConvexNumberBuilderInitial<""> & {
1139
+ kind: ConvexTextBuilderInitial<""> & {
1140
1140
  _: {
1141
1141
  notNull: true;
1142
1142
  };
@@ -1146,10 +1146,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1146
1146
  };
1147
1147
  } & {
1148
1148
  _: {
1149
- fieldName: "updatedAt";
1149
+ fieldName: "kind";
1150
1150
  };
1151
1151
  };
1152
- kind: ConvexTextBuilderInitial<""> & {
1152
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1153
1153
  _: {
1154
1154
  notNull: true;
1155
1155
  };
@@ -1159,10 +1159,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1159
1159
  };
1160
1160
  } & {
1161
1161
  _: {
1162
- fieldName: "kind";
1162
+ fieldName: "updatedAt";
1163
1163
  };
1164
1164
  };
1165
- indexName: ConvexTextBuilderInitial<""> & {
1165
+ tableKey: ConvexTextBuilderInitial<""> & {
1166
1166
  _: {
1167
1167
  notNull: true;
1168
1168
  };
@@ -1172,10 +1172,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1172
1172
  };
1173
1173
  } & {
1174
1174
  _: {
1175
- fieldName: "indexName";
1175
+ fieldName: "tableKey";
1176
1176
  };
1177
1177
  };
1178
- tableKey: ConvexTextBuilderInitial<""> & {
1178
+ indexName: ConvexTextBuilderInitial<""> & {
1179
1179
  _: {
1180
1180
  notNull: true;
1181
1181
  };
@@ -1185,7 +1185,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1185
1185
  };
1186
1186
  } & {
1187
1187
  _: {
1188
- fieldName: "tableKey";
1188
+ fieldName: "indexName";
1189
1189
  };
1190
1190
  };
1191
1191
  keyHash: ConvexTextBuilderInitial<""> & {
@@ -1326,7 +1326,11 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1326
1326
  readonly aggregate_extrema: ConvexTableWithColumns<{
1327
1327
  name: "aggregate_extrema";
1328
1328
  columns: {
1329
- count: ConvexNumberBuilderInitial<""> & {
1329
+ value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
1330
+ _: {
1331
+ $type: convex_values0.Value;
1332
+ };
1333
+ } & {
1330
1334
  _: {
1331
1335
  notNull: true;
1332
1336
  };
@@ -1336,14 +1340,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1336
1340
  };
1337
1341
  } & {
1338
1342
  _: {
1339
- fieldName: "count";
1343
+ fieldName: "value";
1340
1344
  };
1341
1345
  };
1342
- value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
1343
- _: {
1344
- $type: convex_values0.Value;
1345
- };
1346
- } & {
1346
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1347
1347
  _: {
1348
1348
  notNull: true;
1349
1349
  };
@@ -1353,10 +1353,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1353
1353
  };
1354
1354
  } & {
1355
1355
  _: {
1356
- fieldName: "value";
1356
+ fieldName: "updatedAt";
1357
1357
  };
1358
1358
  };
1359
- updatedAt: ConvexNumberBuilderInitial<""> & {
1359
+ tableKey: ConvexTextBuilderInitial<""> & {
1360
1360
  _: {
1361
1361
  notNull: true;
1362
1362
  };
@@ -1366,7 +1366,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1366
1366
  };
1367
1367
  } & {
1368
1368
  _: {
1369
- fieldName: "updatedAt";
1369
+ fieldName: "tableKey";
1370
1370
  };
1371
1371
  };
1372
1372
  indexName: ConvexTextBuilderInitial<""> & {
@@ -1382,7 +1382,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1382
1382
  fieldName: "indexName";
1383
1383
  };
1384
1384
  };
1385
- tableKey: ConvexTextBuilderInitial<""> & {
1385
+ keyHash: ConvexTextBuilderInitial<""> & {
1386
1386
  _: {
1387
1387
  notNull: true;
1388
1388
  };
@@ -1392,10 +1392,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1392
1392
  };
1393
1393
  } & {
1394
1394
  _: {
1395
- fieldName: "tableKey";
1395
+ fieldName: "keyHash";
1396
1396
  };
1397
1397
  };
1398
- keyHash: ConvexTextBuilderInitial<""> & {
1398
+ count: ConvexNumberBuilderInitial<""> & {
1399
1399
  _: {
1400
1400
  notNull: true;
1401
1401
  };
@@ -1405,7 +1405,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1405
1405
  };
1406
1406
  } & {
1407
1407
  _: {
1408
- fieldName: "keyHash";
1408
+ fieldName: "count";
1409
1409
  };
1410
1410
  };
1411
1411
  fieldName: ConvexTextBuilderInitial<""> & {
@@ -1470,6 +1470,15 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1470
1470
  fieldName: "aggregateName";
1471
1471
  };
1472
1472
  };
1473
+ deletionStack: ConvexCustomBuilderInitial<"", convex_values0.VArray<convex_values0.GenericId<"aggregate_rank_node">[], convex_values0.VId<convex_values0.GenericId<"aggregate_rank_node">, "required">, "required">> & {
1474
+ _: {
1475
+ tableName: "aggregate_rank_tree";
1476
+ };
1477
+ } & {
1478
+ _: {
1479
+ fieldName: "deletionStack";
1480
+ };
1481
+ };
1473
1482
  maxNodeSize: ConvexNumberBuilderInitial<""> & {
1474
1483
  _: {
1475
1484
  notNull: true;
@@ -1484,10 +1493,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1484
1493
  };
1485
1494
  };
1486
1495
  namespace: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
1487
- _: {
1488
- $type: convex_values0.Value;
1489
- };
1490
- } & {
1491
1496
  _: {
1492
1497
  tableName: "aggregate_rank_tree";
1493
1498
  };
@@ -1518,14 +1523,13 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1518
1523
  readonly aggregate_rank_node: ConvexTableWithColumns<{
1519
1524
  name: "aggregate_rank_node";
1520
1525
  columns: {
1521
- aggregate: ConvexCustomBuilderInitial<"", ConvexValidatorLike> & {
1522
- _: {
1523
- $type: {
1524
- count: number;
1525
- sum: number;
1526
- };
1527
- };
1528
- } & {
1526
+ aggregate: ConvexCustomBuilderInitial<"", convex_values0.VObject<{
1527
+ count: number;
1528
+ sum: number;
1529
+ }, {
1530
+ count: convex_values0.VFloat64<number, "required">;
1531
+ sum: convex_values0.VFloat64<number, "required">;
1532
+ }, "required", "count" | "sum">> & {
1529
1533
  _: {
1530
1534
  tableName: "aggregate_rank_node";
1531
1535
  };
@@ -1534,15 +1538,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1534
1538
  fieldName: "aggregate";
1535
1539
  };
1536
1540
  };
1537
- items: ConvexCustomBuilderInitial<"", convex_values0.VArray<any[], convex_values0.Validator<any, "required", any>, "required">> & {
1538
- _: {
1539
- $type: {
1540
- k: convex_values0.Value;
1541
- v: convex_values0.Value;
1542
- s: number;
1543
- }[];
1544
- };
1545
- } & {
1541
+ items: ConvexCustomBuilderInitial<"", convex_values0.VArray<{
1542
+ k: any;
1543
+ v: any;
1544
+ s: number;
1545
+ }[], convex_values0.VObject<{
1546
+ k: any;
1547
+ v: any;
1548
+ s: number;
1549
+ }, {
1550
+ k: convex_values0.VAny<any, "required", string>;
1551
+ v: convex_values0.VAny<any, "required", string>;
1552
+ s: convex_values0.VFloat64<number, "required">;
1553
+ }, "required", "k" | "v" | "s" | `k.${string}` | `v.${string}`>, "required">> & {
1546
1554
  _: {
1547
1555
  notNull: true;
1548
1556
  };
@@ -1555,11 +1563,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1555
1563
  fieldName: "items";
1556
1564
  };
1557
1565
  };
1558
- subtrees: ConvexCustomBuilderInitial<"", convex_values0.VArray<any[], convex_values0.Validator<any, "required", any>, "required">> & {
1559
- _: {
1560
- $type: string[];
1561
- };
1562
- } & {
1566
+ subtrees: ConvexCustomBuilderInitial<"", convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">> & {
1563
1567
  _: {
1564
1568
  notNull: true;
1565
1569
  };
@@ -1592,6 +1596,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1592
1596
  fieldName: "status";
1593
1597
  };
1594
1598
  };
1599
+ kind: ConvexTextBuilderInitial<""> & {
1600
+ _: {
1601
+ notNull: true;
1602
+ };
1603
+ } & {
1604
+ _: {
1605
+ tableName: "aggregate_state";
1606
+ };
1607
+ } & {
1608
+ _: {
1609
+ fieldName: "kind";
1610
+ };
1611
+ };
1595
1612
  cursor: ConvexTextBuilderInitial<""> & {
1596
1613
  _: {
1597
1614
  tableName: "aggregate_state";
@@ -1658,7 +1675,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1658
1675
  fieldName: "lastError";
1659
1676
  };
1660
1677
  };
1661
- kind: ConvexTextBuilderInitial<""> & {
1678
+ tableKey: ConvexTextBuilderInitial<""> & {
1662
1679
  _: {
1663
1680
  notNull: true;
1664
1681
  };
@@ -1668,7 +1685,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1668
1685
  };
1669
1686
  } & {
1670
1687
  _: {
1671
- fieldName: "kind";
1688
+ fieldName: "tableKey";
1672
1689
  };
1673
1690
  };
1674
1691
  indexName: ConvexTextBuilderInitial<""> & {
@@ -1710,19 +1727,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1710
1727
  fieldName: "metricDefinitionHash";
1711
1728
  };
1712
1729
  };
1713
- tableKey: ConvexTextBuilderInitial<""> & {
1714
- _: {
1715
- notNull: true;
1716
- };
1717
- } & {
1718
- _: {
1719
- tableName: "aggregate_state";
1720
- };
1721
- } & {
1722
- _: {
1723
- fieldName: "tableKey";
1724
- };
1725
- };
1726
1730
  };
1727
1731
  }, {
1728
1732
  by_creation_time: ["_creationTime"];
@@ -1756,6 +1760,15 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1756
1760
  fieldName: "direction";
1757
1761
  };
1758
1762
  };
1763
+ cursor: ConvexTextBuilderInitial<""> & {
1764
+ _: {
1765
+ tableName: "migration_state";
1766
+ };
1767
+ } & {
1768
+ _: {
1769
+ fieldName: "cursor";
1770
+ };
1771
+ };
1759
1772
  migrationId: ConvexTextBuilderInitial<""> & {
1760
1773
  _: {
1761
1774
  notNull: true;
@@ -1804,15 +1817,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1804
1817
  fieldName: "runId";
1805
1818
  };
1806
1819
  };
1807
- cursor: ConvexTextBuilderInitial<""> & {
1808
- _: {
1809
- tableName: "migration_state";
1810
- };
1811
- } & {
1812
- _: {
1813
- fieldName: "cursor";
1814
- };
1815
- };
1816
1820
  processed: ConvexNumberBuilderInitial<""> & {
1817
1821
  _: {
1818
1822
  notNull: true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",
@@ -262,9 +262,22 @@ Rules:
262
262
  Relation `limit`/`orderBy` are pushed into the relation index when the index
263
263
  already walks in that order. After the FK, `index('by_user').on(t.userId)`
264
264
  orders by creation time, so `with: { posts: { limit: 5, orderBy: { createdAt:
265
- 'desc' } } }` reads 5 posts per parent. Sorting by any other column reads the
266
- parent's whole child partition and sorts in memory — put the sort column in the
267
- relation index (`index('by_user_rank').on(t.userId, t.rank)`) to stay bounded.
265
+ 'desc' } } }` reads 5 posts per parent. Multi-field sorts are pushed down too
266
+ when the index carries all of them: `index('by_user_rank').on(t.userId, t.rank)`
267
+ serves `orderBy: { rank: 'asc', createdAt: 'asc' }`, since the FK pins `userId`,
268
+ `rank` is the next key and `createdAt` is Convex's implicit trailing one.
269
+ Non-null values use Convex value ordering on both index-backed and post-fetch
270
+ paths, including UTF-8 strings, signed zero, and NaN.
271
+ When the first requested field is equality-pinned but points opposite to the
272
+ moving fields, include `createdAt` in the moving direction as the final sort
273
+ field. Without that explicit tie-break, the ORM post-fetch sorts to preserve
274
+ which tied rows survive `limit`.
275
+ Every unpinned declared index key must be requested. An extra key after the
276
+ requested fields would break ties before Convex's implicit creation-time key,
277
+ so the ORM keeps the post-fetch sort to preserve which rows survive `limit`.
278
+ Sorting by any other column — or by one that can be missing or `null` — reads
279
+ the parent's whole child partition and sorts in memory; put the sort columns in
280
+ the relation index, in sort order, to stay bounded.
268
281
 
269
282
  ### Nested `with` depth
270
283
 
@@ -649,6 +662,23 @@ const page2 = await ctx.orm.query.posts.findMany({
649
662
 
650
663
  Return: `{ page, continueCursor, isDone, pageStatus?, splitCursor? }`
651
664
 
665
+ ### Index-union filters
666
+
667
+ `in`, `notIn`, `ne`, and same-field equality `OR` compile to one index range per value when the field is one an index leads with. Cursor pages come from those ranges as a merged stream, so `orderBy` sorts across the whole result and no scan budget is needed.
668
+
669
+ ```ts
670
+ const page = await ctx.orm.query.users.withIndex("by_status").findMany({
671
+ where: { status: { in: ["active", "pending"] } },
672
+ orderBy: { createdAt: "desc" },
673
+ cursor: null,
674
+ limit: 20,
675
+ });
676
+ ```
677
+
678
+ Falls back to a bounded scan (needs `maxScan`) when the probed index cannot supply the requested `orderBy`, or when the union is wider than 64 ranges.
679
+
680
+ Without an `orderBy`, an index-union page is in the order of the index it walks — grouped by the probed value — not in creation order.
681
+
652
682
  ### Boundary pinning with `endCursor`
653
683
 
654
684
  ```ts
@@ -736,7 +766,7 @@ const filtered = results.filter((a) => a.publishedAt >= startDate);
736
766
  ### Performance
737
767
 
738
768
  1. **Index first** — constrain leading index fields. Compound indexes follow prefix rules. Put the `orderBy` column right after the constrained prefix so the scan is already sorted and `limit` bounds the read.
739
- 2. **Bound scans** — use `maxScan` for predicate `where` (cursor mode only). A `.select()` ID-list query with `orderBy` needs a single field that an index leads with.
769
+ 2. **Bound scans** — use `maxScan` for predicate `where` (cursor mode only). `in`/`notIn`/`ne` on an indexed leading field page from index ranges and need no budget. A `.select()` ID-list query with `orderBy` needs a single field that an index leads with.
740
770
  3. **Limit results** — always use `limit` or cursor pagination.
741
771
  4. **Cursor stability** — keep same `where`/`orderBy` between page requests.
742
772
  5. **`allowFullScan`** — non-cursor only. Cursor mode uses `maxScan` instead.
@@ -1,37 +0,0 @@
1
- import { b as ConvexColumnBuilder, x as entityKind } from "./table-d9o_n4R3.js";
2
- import { v } from "convex/values";
3
-
4
- //#region src/orm/builders/id.ts
5
- /**
6
- * ID column builder class
7
- * Compiles to v.id(tableName) or v.optional(v.id(tableName))
8
- */
9
- var ConvexIdBuilder = class extends ConvexColumnBuilder {
10
- static [entityKind] = "ConvexIdBuilder";
11
- constructor(name, tableName) {
12
- super(name, "string", "ConvexId");
13
- this.tableName = tableName;
14
- this.config.referenceTable = tableName;
15
- }
16
- /**
17
- * Expose Convex validator for schema integration
18
- */
19
- get convexValidator() {
20
- if (this.config.notNull) return v.id(this.tableName);
21
- return v.optional(v.union(v.null(), v.id(this.tableName)));
22
- }
23
- /**
24
- * Compile to Convex validator
25
- * .notNull() → v.id(tableName)
26
- * nullable → v.optional(v.id(tableName))
27
- */
28
- build() {
29
- return this.convexValidator;
30
- }
31
- };
32
- function id(tableName) {
33
- return new ConvexIdBuilder("", tableName);
34
- }
35
-
36
- //#endregion
37
- export { id as t };