kitcn 0.31.1 → 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.
- package/CHANGELOG.md +68 -0
- package/dist/aggregate/index.d.ts +2 -2
- package/dist/auth/generated/index.d.ts +1 -1
- package/dist/auth/index.d.ts +11 -11
- package/dist/auth/index.js +2 -2
- package/dist/{capabilities-CG-oIMyR.d.ts → capabilities-CD-Ij91k.d.ts} +38 -0
- package/dist/{generated-contract-disabled-BKvk4lFx.d.ts → generated-contract-disabled-PdNGvNYP.d.ts} +10 -10
- package/dist/{index-utils-C1DyktHe.js → index-utils-DvK7P6Q1.js} +32 -9
- package/dist/orm/aggregate-index/index.d.ts +1 -1
- package/dist/orm/aggregate-index/index.js +2 -2
- package/dist/orm/index.d.ts +2 -2
- package/dist/orm/index.js +326 -131
- package/dist/orm/migrations/index.d.ts +2 -2
- package/dist/{query-context-DdSg3fuk.js → query-context-D4z1CnDH.js} +12 -3
- package/dist/{schema-DbPcDW-N.js → schema-Bh7AmJwY.js} +1 -1
- package/dist/{where-clause-compiler-Bgkzm3Y-.d.ts → where-clause-compiler-FDJTqLDC.d.ts} +56 -56
- package/package.json +1 -1
- package/skills/kitcn/references/features/orm.md +34 -4
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as MigrationStep, D as defineMigration, E as buildMigrationPlan, O as defineMigrationSet, S as MigrationStateMap, T as MigrationWriteMode, _ as MigrationManifestEntry, a as MAX_STATUS_RUN_LIMIT, b as MigrationRunStatus, c as MigrationRunChunkArgs, d as MigrationAppliedState, f as MigrationDefinition, g as MigrationDriftIssue, h as MigrationDocContext, k as detectMigrationDrift, l as MigrationStatusArgs, m as MigrationDoc, o as MigrationCancelArgs, p as MigrationDirection, s as MigrationRunArgs, u as createMigrationHandlers, v as MigrationMigrateOne, w as MigrationTableName, x as MigrationSet, y as MigrationPlan } from "../../capabilities-
|
|
2
|
-
import { Ct as migrationCapability, dt as MIGRATION_STORAGE_TABLE_NAMES, ft as injectMigrationStorageTables, lt as MIGRATION_RUN_TABLE, mt as migrationStorageTables, pt as migrationExtension, ut as MIGRATION_STATE_TABLE } from "../../where-clause-compiler-
|
|
1
|
+
import { C as MigrationStep, D as defineMigration, E as buildMigrationPlan, O as defineMigrationSet, S as MigrationStateMap, T as MigrationWriteMode, _ as MigrationManifestEntry, a as MAX_STATUS_RUN_LIMIT, b as MigrationRunStatus, c as MigrationRunChunkArgs, d as MigrationAppliedState, f as MigrationDefinition, g as MigrationDriftIssue, h as MigrationDocContext, k as detectMigrationDrift, l as MigrationStatusArgs, m as MigrationDoc, o as MigrationCancelArgs, p as MigrationDirection, s as MigrationRunArgs, u as createMigrationHandlers, v as MigrationMigrateOne, w as MigrationTableName, x as MigrationSet, y as MigrationPlan } from "../../capabilities-CD-Ij91k.js";
|
|
2
|
+
import { Ct as migrationCapability, dt as MIGRATION_STORAGE_TABLE_NAMES, ft as injectMigrationStorageTables, lt as MIGRATION_RUN_TABLE, mt as migrationStorageTables, pt as migrationExtension, ut as MIGRATION_STATE_TABLE } from "../../where-clause-compiler-FDJTqLDC.js";
|
|
3
3
|
export { MAX_STATUS_RUN_LIMIT, MIGRATION_RUN_TABLE, MIGRATION_STATE_TABLE, MIGRATION_STORAGE_TABLE_NAMES, type MigrationAppliedState, type MigrationCancelArgs, type MigrationDefinition, type MigrationDirection, type MigrationDoc, type MigrationDocContext, type MigrationDriftIssue, type MigrationManifestEntry, type MigrationMigrateOne, type MigrationPlan, type MigrationRunArgs, type MigrationRunChunkArgs, type MigrationRunStatus, type MigrationSet, type MigrationStateMap, type MigrationStatusArgs, type MigrationStep, type MigrationTableName, type MigrationWriteMode, buildMigrationPlan, createMigrationHandlers, defineMigration, defineMigrationSet, detectMigrationDrift, injectMigrationStorageTables, migrationCapability, migrationExtension, migrationStorageTables };
|
|
@@ -545,6 +545,13 @@ var OrderedStreamQuery = class extends StreamableQuery {
|
|
|
545
545
|
minUpperBound = indexBounds.upperBound;
|
|
546
546
|
minUpperBoundInclusive = indexBounds.upperBoundInclusive;
|
|
547
547
|
}
|
|
548
|
+
if (compareKeys({
|
|
549
|
+
value: maxLowerBound,
|
|
550
|
+
kind: maxLowerBoundInclusive ? "predecessor" : "successor"
|
|
551
|
+
}, {
|
|
552
|
+
value: minUpperBound,
|
|
553
|
+
kind: minUpperBoundInclusive ? "successor" : "predecessor"
|
|
554
|
+
}) >= 0) return new EmptyStream(order, this.getIndexFields(), this.getEqualityIndexFilter());
|
|
548
555
|
return streamIndexRange(db, schema, table, index, {
|
|
549
556
|
lowerBound: maxLowerBound,
|
|
550
557
|
lowerBoundInclusive: maxLowerBoundInclusive,
|
|
@@ -1050,7 +1057,7 @@ var SingletonStream = class SingletonStream extends QueryStream {
|
|
|
1050
1057
|
}
|
|
1051
1058
|
narrow(indexBounds) {
|
|
1052
1059
|
if (indexKeyWithinBounds(this.#indexKey, indexBounds)) return new SingletonStream(this.#value, this.#order, this.#indexFields, this.#indexKey, this.#equalityIndexFilter);
|
|
1053
|
-
return new EmptyStream(this.#order, this.#indexFields);
|
|
1060
|
+
return new EmptyStream(this.#order, this.#indexFields, this.#equalityIndexFilter);
|
|
1054
1061
|
}
|
|
1055
1062
|
};
|
|
1056
1063
|
/**
|
|
@@ -1086,12 +1093,14 @@ function indexKeyWithinBounds(indexKey, indexBounds) {
|
|
|
1086
1093
|
* towards maxScan.
|
|
1087
1094
|
*/
|
|
1088
1095
|
var EmptyStream = class extends QueryStream {
|
|
1096
|
+
#equalityIndexFilter;
|
|
1089
1097
|
#order;
|
|
1090
1098
|
#indexFields;
|
|
1091
|
-
constructor(order, indexFields) {
|
|
1099
|
+
constructor(order, indexFields, equalityIndexFilter = []) {
|
|
1092
1100
|
super();
|
|
1093
1101
|
this.#order = order;
|
|
1094
1102
|
this.#indexFields = indexFields;
|
|
1103
|
+
this.#equalityIndexFilter = equalityIndexFilter;
|
|
1095
1104
|
}
|
|
1096
1105
|
iterWithKeys() {
|
|
1097
1106
|
return { [Symbol.asyncIterator]() {
|
|
@@ -1110,7 +1119,7 @@ var EmptyStream = class extends QueryStream {
|
|
|
1110
1119
|
return this.#indexFields;
|
|
1111
1120
|
}
|
|
1112
1121
|
getEqualityIndexFilter() {
|
|
1113
|
-
return
|
|
1122
|
+
return this.#equalityIndexFilter;
|
|
1114
1123
|
}
|
|
1115
1124
|
narrow(_indexBounds) {
|
|
1116
1125
|
return this;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as json, f as text, h as arrayOf, m as integer, s as index, t as convexTable, v as objectOf } from "./table-d9o_n4R3.js";
|
|
2
2
|
import { a as aggregateTreeTable, n as AGGREGATE_TREE_TABLE, r as aggregateNodeTable, t as AGGREGATE_NODE_TABLE } from "./schema-BFP_awgP.js";
|
|
3
3
|
import { g as TablePolymorphic, h as TableName, i as OrmContext, m as TableDeleteConfig, n as Columns } from "./symbols-DDNAddkd.js";
|
|
4
|
-
import { E as filterValuesEqual, L as matchLikePattern, T as filterValueInList, d as INTERNAL_CREATION_TIME_FIELD, f as PUBLIC_CREATED_AT_FIELD, j as isFieldReference, m as usesSystemCreatedAtAlias, n as findIndexForColumns, p as hasUserCreatedAtColumn, s as getIndexes, t as findExactIndexForColumns, u as CREATED_AT_MIGRATION_MESSAGE, w as fieldRef } from "./index-utils-
|
|
4
|
+
import { E as filterValuesEqual, L as matchLikePattern, T as filterValueInList, d as INTERNAL_CREATION_TIME_FIELD, f as PUBLIC_CREATED_AT_FIELD, j as isFieldReference, m as usesSystemCreatedAtAlias, n as findIndexForColumns, p as hasUserCreatedAtColumn, s as getIndexes, t as findExactIndexForColumns, u as CREATED_AT_MIGRATION_MESSAGE, w as fieldRef } from "./index-utils-DvK7P6Q1.js";
|
|
5
5
|
import { t as defineSchemaExtension } from "./extensions-Bp0XHanR.js";
|
|
6
6
|
|
|
7
7
|
//#region src/internal/concurrency.ts
|
|
@@ -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-
|
|
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";
|
|
@@ -102,20 +102,25 @@ declare const migrationStorageTables: {
|
|
|
102
102
|
fieldName: "status";
|
|
103
103
|
};
|
|
104
104
|
};
|
|
105
|
-
|
|
105
|
+
direction: ConvexTextBuilderInitial<""> & {
|
|
106
106
|
_: {
|
|
107
|
-
|
|
107
|
+
tableName: "migration_state";
|
|
108
108
|
};
|
|
109
109
|
} & {
|
|
110
|
+
_: {
|
|
111
|
+
fieldName: "direction";
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
cursor: ConvexTextBuilderInitial<""> & {
|
|
110
115
|
_: {
|
|
111
116
|
tableName: "migration_state";
|
|
112
117
|
};
|
|
113
118
|
} & {
|
|
114
119
|
_: {
|
|
115
|
-
fieldName: "
|
|
120
|
+
fieldName: "cursor";
|
|
116
121
|
};
|
|
117
122
|
};
|
|
118
|
-
|
|
123
|
+
migrationId: ConvexTextBuilderInitial<""> & {
|
|
119
124
|
_: {
|
|
120
125
|
notNull: true;
|
|
121
126
|
};
|
|
@@ -125,10 +130,10 @@ declare const migrationStorageTables: {
|
|
|
125
130
|
};
|
|
126
131
|
} & {
|
|
127
132
|
_: {
|
|
128
|
-
fieldName: "
|
|
133
|
+
fieldName: "migrationId";
|
|
129
134
|
};
|
|
130
135
|
};
|
|
131
|
-
|
|
136
|
+
checksum: ConvexTextBuilderInitial<""> & {
|
|
132
137
|
_: {
|
|
133
138
|
notNull: true;
|
|
134
139
|
};
|
|
@@ -138,34 +143,29 @@ declare const migrationStorageTables: {
|
|
|
138
143
|
};
|
|
139
144
|
} & {
|
|
140
145
|
_: {
|
|
141
|
-
fieldName: "
|
|
146
|
+
fieldName: "checksum";
|
|
142
147
|
};
|
|
143
148
|
};
|
|
144
|
-
|
|
149
|
+
applied: ConvexBooleanBuilderInitial<""> & {
|
|
145
150
|
_: {
|
|
146
|
-
|
|
151
|
+
notNull: true;
|
|
147
152
|
};
|
|
148
153
|
} & {
|
|
149
|
-
_: {
|
|
150
|
-
fieldName: "direction";
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
runId: ConvexTextBuilderInitial<""> & {
|
|
154
154
|
_: {
|
|
155
155
|
tableName: "migration_state";
|
|
156
156
|
};
|
|
157
157
|
} & {
|
|
158
158
|
_: {
|
|
159
|
-
fieldName: "
|
|
159
|
+
fieldName: "applied";
|
|
160
160
|
};
|
|
161
161
|
};
|
|
162
|
-
|
|
162
|
+
runId: ConvexTextBuilderInitial<""> & {
|
|
163
163
|
_: {
|
|
164
164
|
tableName: "migration_state";
|
|
165
165
|
};
|
|
166
166
|
} & {
|
|
167
167
|
_: {
|
|
168
|
-
fieldName: "
|
|
168
|
+
fieldName: "runId";
|
|
169
169
|
};
|
|
170
170
|
};
|
|
171
171
|
processed: ConvexNumberBuilderInitial<""> & {
|
|
@@ -1024,19 +1024,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1024
1024
|
fieldName: "updatedAt";
|
|
1025
1025
|
};
|
|
1026
1026
|
};
|
|
1027
|
-
count: ConvexNumberBuilderInitial<""> & {
|
|
1028
|
-
_: {
|
|
1029
|
-
notNull: true;
|
|
1030
|
-
};
|
|
1031
|
-
} & {
|
|
1032
|
-
_: {
|
|
1033
|
-
tableName: "aggregate_bucket";
|
|
1034
|
-
};
|
|
1035
|
-
} & {
|
|
1036
|
-
_: {
|
|
1037
|
-
fieldName: "count";
|
|
1038
|
-
};
|
|
1039
|
-
};
|
|
1040
1027
|
tableKey: ConvexTextBuilderInitial<""> & {
|
|
1041
1028
|
_: {
|
|
1042
1029
|
notNull: true;
|
|
@@ -1093,6 +1080,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1093
1080
|
fieldName: "keyParts";
|
|
1094
1081
|
};
|
|
1095
1082
|
};
|
|
1083
|
+
count: ConvexNumberBuilderInitial<""> & {
|
|
1084
|
+
_: {
|
|
1085
|
+
notNull: true;
|
|
1086
|
+
};
|
|
1087
|
+
} & {
|
|
1088
|
+
_: {
|
|
1089
|
+
tableName: "aggregate_bucket";
|
|
1090
|
+
};
|
|
1091
|
+
} & {
|
|
1092
|
+
_: {
|
|
1093
|
+
fieldName: "count";
|
|
1094
|
+
};
|
|
1095
|
+
};
|
|
1096
1096
|
sumValues: ConvexCustomBuilderInitial<"", ConvexValidatorLike> & {
|
|
1097
1097
|
_: {
|
|
1098
1098
|
$type: Record<string, number>;
|
|
@@ -1356,7 +1356,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1356
1356
|
fieldName: "updatedAt";
|
|
1357
1357
|
};
|
|
1358
1358
|
};
|
|
1359
|
-
|
|
1359
|
+
tableKey: ConvexTextBuilderInitial<""> & {
|
|
1360
1360
|
_: {
|
|
1361
1361
|
notNull: true;
|
|
1362
1362
|
};
|
|
@@ -1366,10 +1366,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1366
1366
|
};
|
|
1367
1367
|
} & {
|
|
1368
1368
|
_: {
|
|
1369
|
-
fieldName: "
|
|
1369
|
+
fieldName: "tableKey";
|
|
1370
1370
|
};
|
|
1371
1371
|
};
|
|
1372
|
-
|
|
1372
|
+
indexName: ConvexTextBuilderInitial<""> & {
|
|
1373
1373
|
_: {
|
|
1374
1374
|
notNull: true;
|
|
1375
1375
|
};
|
|
@@ -1379,10 +1379,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1379
1379
|
};
|
|
1380
1380
|
} & {
|
|
1381
1381
|
_: {
|
|
1382
|
-
fieldName: "
|
|
1382
|
+
fieldName: "indexName";
|
|
1383
1383
|
};
|
|
1384
1384
|
};
|
|
1385
|
-
|
|
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: "
|
|
1395
|
+
fieldName: "keyHash";
|
|
1396
1396
|
};
|
|
1397
1397
|
};
|
|
1398
|
-
|
|
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: "
|
|
1408
|
+
fieldName: "count";
|
|
1409
1409
|
};
|
|
1410
1410
|
};
|
|
1411
1411
|
fieldName: ConvexTextBuilderInitial<""> & {
|
|
@@ -1751,20 +1751,25 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1751
1751
|
fieldName: "status";
|
|
1752
1752
|
};
|
|
1753
1753
|
};
|
|
1754
|
-
|
|
1754
|
+
direction: ConvexTextBuilderInitial<""> & {
|
|
1755
1755
|
_: {
|
|
1756
|
-
|
|
1756
|
+
tableName: "migration_state";
|
|
1757
1757
|
};
|
|
1758
1758
|
} & {
|
|
1759
|
+
_: {
|
|
1760
|
+
fieldName: "direction";
|
|
1761
|
+
};
|
|
1762
|
+
};
|
|
1763
|
+
cursor: ConvexTextBuilderInitial<""> & {
|
|
1759
1764
|
_: {
|
|
1760
1765
|
tableName: "migration_state";
|
|
1761
1766
|
};
|
|
1762
1767
|
} & {
|
|
1763
1768
|
_: {
|
|
1764
|
-
fieldName: "
|
|
1769
|
+
fieldName: "cursor";
|
|
1765
1770
|
};
|
|
1766
1771
|
};
|
|
1767
|
-
|
|
1772
|
+
migrationId: ConvexTextBuilderInitial<""> & {
|
|
1768
1773
|
_: {
|
|
1769
1774
|
notNull: true;
|
|
1770
1775
|
};
|
|
@@ -1774,10 +1779,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1774
1779
|
};
|
|
1775
1780
|
} & {
|
|
1776
1781
|
_: {
|
|
1777
|
-
fieldName: "
|
|
1782
|
+
fieldName: "migrationId";
|
|
1778
1783
|
};
|
|
1779
1784
|
};
|
|
1780
|
-
|
|
1785
|
+
checksum: ConvexTextBuilderInitial<""> & {
|
|
1781
1786
|
_: {
|
|
1782
1787
|
notNull: true;
|
|
1783
1788
|
};
|
|
@@ -1787,34 +1792,29 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
1787
1792
|
};
|
|
1788
1793
|
} & {
|
|
1789
1794
|
_: {
|
|
1790
|
-
fieldName: "
|
|
1795
|
+
fieldName: "checksum";
|
|
1791
1796
|
};
|
|
1792
1797
|
};
|
|
1793
|
-
|
|
1798
|
+
applied: ConvexBooleanBuilderInitial<""> & {
|
|
1794
1799
|
_: {
|
|
1795
|
-
|
|
1800
|
+
notNull: true;
|
|
1796
1801
|
};
|
|
1797
1802
|
} & {
|
|
1798
|
-
_: {
|
|
1799
|
-
fieldName: "direction";
|
|
1800
|
-
};
|
|
1801
|
-
};
|
|
1802
|
-
runId: ConvexTextBuilderInitial<""> & {
|
|
1803
1803
|
_: {
|
|
1804
1804
|
tableName: "migration_state";
|
|
1805
1805
|
};
|
|
1806
1806
|
} & {
|
|
1807
1807
|
_: {
|
|
1808
|
-
fieldName: "
|
|
1808
|
+
fieldName: "applied";
|
|
1809
1809
|
};
|
|
1810
1810
|
};
|
|
1811
|
-
|
|
1811
|
+
runId: ConvexTextBuilderInitial<""> & {
|
|
1812
1812
|
_: {
|
|
1813
1813
|
tableName: "migration_state";
|
|
1814
1814
|
};
|
|
1815
1815
|
} & {
|
|
1816
1816
|
_: {
|
|
1817
|
-
fieldName: "
|
|
1817
|
+
fieldName: "runId";
|
|
1818
1818
|
};
|
|
1819
1819
|
};
|
|
1820
1820
|
processed: ConvexNumberBuilderInitial<""> & {
|
package/package.json
CHANGED
|
@@ -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.
|
|
266
|
-
|
|
267
|
-
|
|
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.
|