You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add optional compareOptions to the Collection Config which act as col… (#762)
* Add optional compareOptions to the Collection Config which act as collection-wide config and allow queries to override those.
* Fix import
* changeset
* Ran prettier
* update docs
* Live queries inherit compare options from collection in the FROM clause
* Explicit compare options for live queries
* Rename compareOptions to defaultStringCollation in the collection config and live query collection config
* Docs update
---------
Co-authored-by: Sam Willis <[email protected]>
function electricCollectionOptions<T>(config):CollectionConfig<InferSchemaOutput<T>, string|number, T, UtilsRecord> &object;
12
12
```
13
13
14
-
Defined in: [packages/electric-db-collection/src/electric.ts:254](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L254)
14
+
Defined in: [packages/electric-db-collection/src/electric.ts:277](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L277)
15
15
16
16
Creates Electric collection options for use with a standard Collection
17
17
@@ -43,7 +43,7 @@ Collection options with utilities
43
43
function electricCollectionOptions<T>(config):CollectionConfig<T, string|number, never, UtilsRecord> &object;
44
44
```
45
45
46
-
Defined in: [packages/electric-db-collection/src/electric.ts:265](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L265)
46
+
Defined in: [packages/electric-db-collection/src/electric.ts:288](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L288)
47
47
48
48
Creates Electric collection options for use with a standard Collection
Defined in: [packages/electric-db-collection/src/electric.ts:80](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L80)
8
+
Defined in: [packages/electric-db-collection/src/electric.ts:102](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L102)
9
9
10
10
Configuration interface for Electric collection options
Defined in: [packages/electric-db-collection/src/electric.ts:185](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L185)
38
+
Defined in: [packages/electric-db-collection/src/electric.ts:208](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L208)
39
39
40
40
Optional asynchronous handler function called before a delete operation
Defined in: [packages/electric-db-collection/src/electric.ts:128](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L128)
90
+
Defined in: [packages/electric-db-collection/src/electric.ts:151](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L151)
91
91
92
92
Optional asynchronous handler function called before an insert operation
Defined in: [packages/electric-db-collection/src/electric.ts:157](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L157)
153
+
Defined in: [packages/electric-db-collection/src/electric.ts:180](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L180)
154
154
155
155
Optional asynchronous handler function called before an update operation
Defined in: [packages/electric-db-collection/src/electric.ts:90](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L90)
206
+
Defined in: [packages/electric-db-collection/src/electric.ts:112](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L112)
207
207
208
208
Configuration options for the ElectricSQL ShapeStream
209
+
210
+
***
211
+
212
+
### syncMode?
213
+
214
+
```ts
215
+
optionalsyncMode: ElectricSyncMode;
216
+
```
217
+
218
+
Defined in: [packages/electric-db-collection/src/electric.ts:113](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L113)
Copy file name to clipboardExpand all lines: docs/reference/electric-db-collection/interfaces/ElectricCollectionUtils.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ title: ElectricCollectionUtils
5
5
6
6
# Interface: ElectricCollectionUtils\<T\>
7
7
8
-
Defined in: [packages/electric-db-collection/src/electric.ts:237](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L237)
8
+
Defined in: [packages/electric-db-collection/src/electric.ts:260](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L260)
9
9
10
10
Electric collection utilities type
11
11
@@ -33,7 +33,7 @@ Electric collection utilities type
33
33
awaitMatch: AwaitMatchFn<T>;
34
34
```
35
35
36
-
Defined in: [packages/electric-db-collection/src/electric.ts:240](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L240)
36
+
Defined in: [packages/electric-db-collection/src/electric.ts:263](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L263)
37
37
38
38
***
39
39
@@ -43,4 +43,4 @@ Defined in: [packages/electric-db-collection/src/electric.ts:240](https://github
43
43
awaitTxId: AwaitTxIdFn;
44
44
```
45
45
46
-
Defined in: [packages/electric-db-collection/src/electric.ts:239](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L239)
46
+
Defined in: [packages/electric-db-collection/src/electric.ts:262](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L262)
Defined in: [packages/electric-db-collection/src/electric.ts:224](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L224)
12
+
Defined in: [packages/electric-db-collection/src/electric.ts:247](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L247)
Copy file name to clipboardExpand all lines: docs/reference/electric-db-collection/type-aliases/Txid.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,6 @@ title: Txid
9
9
typeTxid=number;
10
10
```
11
11
12
-
Defined in: [packages/electric-db-collection/src/electric.ts:42](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L42)
12
+
Defined in: [packages/electric-db-collection/src/electric.ts:46](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L46)
Copy file name to clipboardExpand all lines: docs/reference/functions/createCollection.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ title: createCollection
11
11
function createCollection<T, TKey, TUtils>(options):Collection<InferSchemaOutput<T>, TKey, TUtils, T, InferSchemaInput<T>> &NonSingleResult;
12
12
```
13
13
14
-
Defined in: [packages/db/src/collection/index.ts:130](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L130)
14
+
Defined in: [packages/db/src/collection/index.ts:131](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L131)
15
15
16
16
Creates a new Collection instance with the given configuration
17
17
@@ -120,7 +120,7 @@ const todos = createCollection({
120
120
function createCollection<T, TKey, TUtils>(options):Collection<InferSchemaOutput<T>, TKey, TUtils, T, InferSchemaInput<T>> &SingleResult;
121
121
```
122
122
123
-
Defined in: [packages/db/src/collection/index.ts:143](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L143)
123
+
Defined in: [packages/db/src/collection/index.ts:144](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L144)
124
124
125
125
Creates a new Collection instance with the given configuration
126
126
@@ -229,7 +229,7 @@ const todos = createCollection({
229
229
function createCollection<T, TKey, TUtils>(options):Collection<T, TKey, TUtils, never, T> &NonSingleResult;
230
230
```
231
231
232
-
Defined in: [packages/db/src/collection/index.ts:157](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L157)
232
+
Defined in: [packages/db/src/collection/index.ts:158](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L158)
233
233
234
234
Creates a new Collection instance with the given configuration
235
235
@@ -338,7 +338,7 @@ const todos = createCollection({
338
338
function createCollection<T, TKey, TUtils>(options):Collection<T, TKey, TUtils, never, T> &SingleResult;
339
339
```
340
340
341
-
Defined in: [packages/db/src/collection/index.ts:170](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L170)
341
+
Defined in: [packages/db/src/collection/index.ts:171](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L171)
342
342
343
343
Creates a new Collection instance with the given configuration
Defined in: [packages/db/src/types.ts:385](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L385)
8
+
Defined in: [packages/db/src/types.ts:416](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L416)
9
9
10
10
## Extended by
11
11
@@ -42,7 +42,7 @@ Defined in: [packages/db/src/types.ts:385](https://github.com/TanStack/db/blob/m
42
42
optionalautoIndex: "eager"|"off";
43
43
```
44
44
45
-
Defined in: [packages/db/src/types.ts:434](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L434)
45
+
Defined in: [packages/db/src/types.ts:465](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L465)
46
46
47
47
Auto-indexing mode for the collection.
48
48
When enabled, indexes will be automatically created for simple where expressions.
@@ -66,7 +66,7 @@ When enabled, indexes will be automatically created for simple where expressions
66
66
optionalcompare: (x, y) =>number;
67
67
```
68
68
69
-
Defined in: [packages/db/src/types.ts:445](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L445)
69
+
Defined in: [packages/db/src/types.ts:476](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L476)
70
70
71
71
Optional function to compare two items.
72
72
This is used to order the items in the collection.
Defined in: [packages/db/src/types.ts:622](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L622)
110
+
111
+
Specifies how to compare data in the collection.
112
+
This should be configured to match data ordering on the backend.
113
+
E.g., when using the Electric DB collection these options
114
+
should match the database's collation settings.
115
+
116
+
***
117
+
103
118
### gcTime?
104
119
105
120
```ts
106
121
optionalgcTime: number;
107
122
```
108
123
109
-
Defined in: [packages/db/src/types.ts:414](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L414)
124
+
Defined in: [packages/db/src/types.ts:445](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L445)
110
125
111
126
Time in milliseconds after which the collection will be garbage collected
112
127
when it has no active subscribers. Defaults to 5 minutes (300000ms).
@@ -119,7 +134,7 @@ when it has no active subscribers. Defaults to 5 minutes (300000ms).
119
134
getKey: (item) =>TKey;
120
135
```
121
136
122
-
Defined in: [packages/db/src/types.ts:409](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L409)
137
+
Defined in: [packages/db/src/types.ts:440](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L440)
123
138
124
139
Function to extract the ID from an object
125
140
This is required for update/delete operations which now only accept IDs
@@ -153,7 +168,7 @@ getKey: (item) => item.uuid
153
168
optionalid: string;
154
169
```
155
170
156
-
Defined in: [packages/db/src/types.ts:398](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L398)
171
+
Defined in: [packages/db/src/types.ts:429](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L429)
157
172
158
173
***
159
174
@@ -163,7 +178,7 @@ Defined in: [packages/db/src/types.ts:398](https://github.com/TanStack/db/blob/m
Defined in: [packages/db/src/types.ts:583](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L583)
181
+
Defined in: [packages/db/src/types.ts:614](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L614)
167
182
168
183
Optional asynchronous handler function called before a delete operation
Defined in: [packages/db/src/types.ts:496](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L496)
245
+
Defined in: [packages/db/src/types.ts:527](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L527)
231
246
232
247
Optional asynchronous handler function called before an insert operation
Defined in: [packages/db/src/types.ts:540](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L540)
308
+
Defined in: [packages/db/src/types.ts:571](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L571)
294
309
295
310
Optional asynchronous handler function called before an update operation
Defined in: [packages/db/src/types.ts:399](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L399)
372
+
Defined in: [packages/db/src/types.ts:430](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L430)
358
373
359
374
***
360
375
@@ -364,7 +379,7 @@ Defined in: [packages/db/src/types.ts:399](https://github.com/TanStack/db/blob/m
364
379
optionalstartSync: boolean;
365
380
```
366
381
367
-
Defined in: [packages/db/src/types.ts:425](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L425)
382
+
Defined in: [packages/db/src/types.ts:456](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L456)
368
383
369
384
Whether to eagerly start syncing on collection creation.
370
385
When true, syncing begins immediately. When false, syncing starts when the first subscriber attaches.
@@ -387,7 +402,7 @@ false
387
402
optionalsyncMode: SyncMode;
388
403
```
389
404
390
-
Defined in: [packages/db/src/types.ts:454](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L454)
405
+
Defined in: [packages/db/src/types.ts:485](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L485)
391
406
392
407
The mode of sync to use for the collection.
393
408
@@ -409,4 +424,4 @@ The exact implementation of the sync mode is up to the sync implementation.
409
424
optionalutils: TUtils;
410
425
```
411
426
412
-
Defined in: [packages/db/src/types.ts:585](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L585)
427
+
Defined in: [packages/db/src/types.ts:624](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L624)
0 commit comments