Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 42 additions & 38 deletions docs/reference/classes/CollectionImpl.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ title: electricCollectionOptions
function electricCollectionOptions<T>(config): Omit<CollectionConfig<InferSchemaOutput<T>, string | number, T, UtilsRecord>, "utils"> & object;
```

Defined in: [packages/electric-db-collection/src/electric.ts:427](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L427)
Defined in: [packages/electric-db-collection/src/electric.ts:474](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L474)

Creates Electric collection options for use with a standard Collection

Expand Down Expand Up @@ -43,7 +43,7 @@ Collection options with utilities
function electricCollectionOptions<T>(config): Omit<CollectionConfig<T, string | number, never, UtilsRecord>, "utils"> & object;
```

Defined in: [packages/electric-db-collection/src/electric.ts:438](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L438)
Defined in: [packages/electric-db-collection/src/electric.ts:485](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L485)

Creates Electric collection options for use with a standard Collection

Expand Down
46 changes: 46 additions & 0 deletions docs/reference/electric-db-collection/functions/isChangeMessage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
id: isChangeMessage
title: isChangeMessage
---

# Function: isChangeMessage()

```ts
function isChangeMessage<T>(message): message is ChangeMessage<T>;
```

Defined in: node\_modules/.pnpm/@electric-sql+client@1.2.0/node\_modules/@electric-sql/client/dist/index.d.ts:783

Type guard for checking Message is ChangeMessage.

See [TS docs](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards)
for information on how to use type guards.

## Type Parameters

### T

`T` *extends* `Row`\<`unknown`\> = `Row`\<`never`\>

## Parameters

### message

`Message`\<`T`\>

the message to check

## Returns

`message is ChangeMessage<T>`

true if the message is a ChangeMessage

## Example

```ts
if (isChangeMessage(message)) {
const msgChng: ChangeMessage = message // Ok
const msgCtrl: ControlMessage = message // Err, type mismatch
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
id: isControlMessage
title: isControlMessage
---

# Function: isControlMessage()

```ts
function isControlMessage<T>(message): message is ControlMessage;
```

Defined in: node\_modules/.pnpm/@electric-sql+client@1.2.0/node\_modules/@electric-sql/client/dist/index.d.ts:801

Type guard for checking Message is ControlMessage.

See [TS docs](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards)
for information on how to use type guards.

## Type Parameters

### T

`T` *extends* `Row`\<`unknown`\> = `Row`\<`never`\>

## Parameters

### message

`Message`\<`T`\>

the message to check

## Returns

`message is ControlMessage`

true if the message is a ControlMessage

*

## Example

```ts
if (isControlMessage(message)) {
const msgChng: ChangeMessage = message // Err, type mismatch
const msgCtrl: ControlMessage = message // Ok
}
```
2 changes: 2 additions & 0 deletions docs/reference/electric-db-collection/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ title: "@tanstack/electric-db-collection"
## Functions

- [electricCollectionOptions](functions/electricCollectionOptions.md)
- [isChangeMessage](functions/isChangeMessage.md)
- [isControlMessage](functions/isControlMessage.md)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: ElectricCollectionUtils

# Interface: ElectricCollectionUtils\<T\>

Defined in: [packages/electric-db-collection/src/electric.ts:409](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L409)
Defined in: [packages/electric-db-collection/src/electric.ts:456](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L456)

Electric collection utilities type

Expand Down Expand Up @@ -33,7 +33,7 @@ Electric collection utilities type
awaitMatch: AwaitMatchFn<T>;
```

Defined in: [packages/electric-db-collection/src/electric.ts:413](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L413)
Defined in: [packages/electric-db-collection/src/electric.ts:460](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L460)

***

Expand All @@ -43,4 +43,4 @@ Defined in: [packages/electric-db-collection/src/electric.ts:413](https://github
awaitTxId: AwaitTxIdFn;
```

Defined in: [packages/electric-db-collection/src/electric.ts:412](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L412)
Defined in: [packages/electric-db-collection/src/electric.ts:459](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L459)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ title: AwaitTxIdFn
type AwaitTxIdFn = (txId, timeout?) => Promise<boolean>;
```

Defined in: [packages/electric-db-collection/src/electric.ts:396](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L396)
Defined in: [packages/electric-db-collection/src/electric.ts:443](https://github.com/TanStack/db/blob/main/packages/electric-db-collection/src/electric.ts#L443)

Type for the awaitTxId utility function

Expand Down
5 changes: 4 additions & 1 deletion docs/reference/functions/isLimitSubset.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ title: isLimitSubset
function isLimitSubset(subset, superset): boolean;
```

Defined in: [packages/db/src/query/predicate-utils.ts:768](https://github.com/TanStack/db/blob/main/packages/db/src/query/predicate-utils.ts#L768)
Defined in: [packages/db/src/query/predicate-utils.ts:771](https://github.com/TanStack/db/blob/main/packages/db/src/query/predicate-utils.ts#L771)

Check if one limit is a subset of another.
Returns true if the subset limit requirements are satisfied by the superset limit.

Note: This function does NOT consider offset. For offset-aware subset checking,
use `isOffsetLimitSubset` instead.

## Parameters

### subset
Expand Down
63 changes: 63 additions & 0 deletions docs/reference/functions/isOffsetLimitSubset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
id: isOffsetLimitSubset
title: isOffsetLimitSubset
---

# Function: isOffsetLimitSubset()

```ts
function isOffsetLimitSubset(subset, superset): boolean;
```

Defined in: [packages/db/src/query/predicate-utils.ts:811](https://github.com/TanStack/db/blob/main/packages/db/src/query/predicate-utils.ts#L811)

Check if one offset+limit range is a subset of another.
Returns true if the subset range is fully contained within the superset range.

A query with `{limit: 10, offset: 0}` loads rows [0, 10).
A query with `{limit: 10, offset: 20}` loads rows [20, 30).

For subset to be satisfied by superset:
- Superset must start at or before subset (superset.offset <= subset.offset)
- Superset must end at or after subset (superset.offset + superset.limit >= subset.offset + subset.limit)

## Parameters

### subset

The offset+limit requirements to check

#### limit?

`number`

#### offset?

`number`

### superset

The offset+limit that might satisfy the requirements

#### limit?

`number`

#### offset?

`number`

## Returns

`boolean`

true if subset range is fully contained within superset range

## Example

```ts
isOffsetLimitSubset({ offset: 0, limit: 5 }, { offset: 0, limit: 10 }) // true
isOffsetLimitSubset({ offset: 5, limit: 5 }, { offset: 0, limit: 10 }) // true (rows 5-9 within 0-9)
isOffsetLimitSubset({ offset: 5, limit: 10 }, { offset: 0, limit: 10 }) // false (rows 5-14 exceed 0-9)
isOffsetLimitSubset({ offset: 20, limit: 10 }, { offset: 0, limit: 10 }) // false (rows 20-29 outside 0-9)
```
4 changes: 2 additions & 2 deletions docs/reference/functions/isPredicateSubset.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ title: isPredicateSubset
function isPredicateSubset(subset, superset): boolean;
```

Defined in: [packages/db/src/query/predicate-utils.ts:801](https://github.com/TanStack/db/blob/main/packages/db/src/query/predicate-utils.ts#L801)
Defined in: [packages/db/src/query/predicate-utils.ts:854](https://github.com/TanStack/db/blob/main/packages/db/src/query/predicate-utils.ts#L854)

Check if one predicate (where + orderBy + limit) is a subset of another.
Check if one predicate (where + orderBy + limit + offset) is a subset of another.
Returns true if all aspects of the subset predicate are satisfied by the superset.

## Parameters
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ title: "@tanstack/db"
- [ClearStorageFn](type-aliases/ClearStorageFn.md)
- [CollectionConfigSingleRowOption](type-aliases/CollectionConfigSingleRowOption.md)
- [CollectionStatus](type-aliases/CollectionStatus.md)
- [CursorExpressions](type-aliases/CursorExpressions.md)
- [DeleteMutationFn](type-aliases/DeleteMutationFn.md)
- [DeleteMutationFnParams](type-aliases/DeleteMutationFnParams.md)
- [FieldPath](type-aliases/FieldPath.md)
Expand Down Expand Up @@ -249,6 +250,7 @@ title: "@tanstack/db"
- [inArray](functions/inArray.md)
- [isLimitSubset](functions/isLimitSubset.md)
- [isNull](functions/isNull.md)
- [isOffsetLimitSubset](functions/isOffsetLimitSubset.md)
- [isOrderBySubset](functions/isOrderBySubset.md)
- [isPredicateSubset](functions/isPredicateSubset.md)
- [isUndefined](functions/isUndefined.md)
Expand Down
28 changes: 14 additions & 14 deletions docs/reference/interfaces/BaseCollectionConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: BaseCollectionConfig

# Interface: BaseCollectionConfig\<T, TKey, TSchema, TUtils, TReturn\>

Defined in: [packages/db/src/types.ts:438](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L438)
Defined in: [packages/db/src/types.ts:477](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L477)

## Extended by

Expand Down Expand Up @@ -42,7 +42,7 @@ Defined in: [packages/db/src/types.ts:438](https://github.com/TanStack/db/blob/m
optional autoIndex: "eager" | "off";
```

Defined in: [packages/db/src/types.ts:487](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L487)
Defined in: [packages/db/src/types.ts:526](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L526)

Auto-indexing mode for the collection.
When enabled, indexes will be automatically created for simple where expressions.
Expand All @@ -66,7 +66,7 @@ When enabled, indexes will be automatically created for simple where expressions
optional compare: (x, y) => number;
```

Defined in: [packages/db/src/types.ts:498](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L498)
Defined in: [packages/db/src/types.ts:537](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L537)

Optional function to compare two items.
This is used to order the items in the collection.
Expand Down Expand Up @@ -106,7 +106,7 @@ compare: (x, y) => x.createdAt.getTime() - y.createdAt.getTime()
optional defaultStringCollation: StringCollationConfig;
```

Defined in: [packages/db/src/types.ts:644](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L644)
Defined in: [packages/db/src/types.ts:683](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L683)

Specifies how to compare data in the collection.
This should be configured to match data ordering on the backend.
Expand All @@ -121,7 +121,7 @@ E.g., when using the Electric DB collection these options
optional gcTime: number;
```

Defined in: [packages/db/src/types.ts:467](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L467)
Defined in: [packages/db/src/types.ts:506](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L506)

Time in milliseconds after which the collection will be garbage collected
when it has no active subscribers. Defaults to 5 minutes (300000ms).
Expand All @@ -134,7 +134,7 @@ when it has no active subscribers. Defaults to 5 minutes (300000ms).
getKey: (item) => TKey;
```

Defined in: [packages/db/src/types.ts:462](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L462)
Defined in: [packages/db/src/types.ts:501](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L501)

Function to extract the ID from an object
This is required for update/delete operations which now only accept IDs
Expand Down Expand Up @@ -168,7 +168,7 @@ getKey: (item) => item.uuid
optional id: string;
```

Defined in: [packages/db/src/types.ts:451](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L451)
Defined in: [packages/db/src/types.ts:490](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L490)

***

Expand All @@ -178,7 +178,7 @@ Defined in: [packages/db/src/types.ts:451](https://github.com/TanStack/db/blob/m
optional onDelete: DeleteMutationFn<T, TKey, TUtils, TReturn>;
```

Defined in: [packages/db/src/types.ts:636](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L636)
Defined in: [packages/db/src/types.ts:675](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L675)

Optional asynchronous handler function called before a delete operation

Expand Down Expand Up @@ -242,7 +242,7 @@ onDelete: async ({ transaction, collection }) => {
optional onInsert: InsertMutationFn<T, TKey, TUtils, TReturn>;
```

Defined in: [packages/db/src/types.ts:549](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L549)
Defined in: [packages/db/src/types.ts:588](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L588)

Optional asynchronous handler function called before an insert operation

Expand Down Expand Up @@ -305,7 +305,7 @@ onInsert: async ({ transaction, collection }) => {
optional onUpdate: UpdateMutationFn<T, TKey, TUtils, TReturn>;
```

Defined in: [packages/db/src/types.ts:593](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L593)
Defined in: [packages/db/src/types.ts:632](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L632)

Optional asynchronous handler function called before an update operation

Expand Down Expand Up @@ -369,7 +369,7 @@ onUpdate: async ({ transaction, collection }) => {
optional schema: TSchema;
```

Defined in: [packages/db/src/types.ts:452](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L452)
Defined in: [packages/db/src/types.ts:491](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L491)

***

Expand All @@ -379,7 +379,7 @@ Defined in: [packages/db/src/types.ts:452](https://github.com/TanStack/db/blob/m
optional startSync: boolean;
```

Defined in: [packages/db/src/types.ts:478](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L478)
Defined in: [packages/db/src/types.ts:517](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L517)

Whether to eagerly start syncing on collection creation.
When true, syncing begins immediately. When false, syncing starts when the first subscriber attaches.
Expand All @@ -402,7 +402,7 @@ false
optional syncMode: SyncMode;
```

Defined in: [packages/db/src/types.ts:507](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L507)
Defined in: [packages/db/src/types.ts:546](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L546)

The mode of sync to use for the collection.

Expand All @@ -424,4 +424,4 @@ The exact implementation of the sync mode is up to the sync implementation.
optional utils: TUtils;
```

Defined in: [packages/db/src/types.ts:646](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L646)
Defined in: [packages/db/src/types.ts:685](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L685)
Loading