Skip to content

Commit

Permalink
docs: replica parameter (#1812)
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetised authored Nov 5, 2024
1 parent c521679 commit 4d6bab8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
23 changes: 23 additions & 0 deletions website/docs/api/clients/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ stream.subscribe(messages => {
#### Custom parsing

By default, `ShapeStream` parses the following Postgres types into native JavaScript values:

- `int2`, `int4`, `float4`, and `float8` are parsed into JavaScript `Number`
- `int8` is parsed into a JavaScript `BigInt`
- `bool` is parsed into a JavaScript `Boolean`
Expand All @@ -62,6 +63,28 @@ const stream = new ShapeStream({
})
```

#### `Replica`

By default Electric only sends the modified columns in an update message, not
the complete row. If your use case requires the receipt of the full row, not just
the modified columns, then set the `replica` of your `ShapeStream` to `full`:

```tsx
import { ShapeStream } from "@electric-sql/client"

const stream = new ShapeStream({
url: `http://localhost:3000/v1/shape`,
table: `foo`,
replica: `full`,
})
```

This is less efficient and will use much more bandwidth for the same shape,
especially for tables with large static column values.

Shapes with differing `replica` settings are distinct, even for the same table
and where clause combination.

### `Shape`

```tsx
Expand Down
16 changes: 16 additions & 0 deletions website/electric-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,22 @@ paths:
select_columns_special:
value: 'id,"Status-Check"'
summary: Only include id and Status-Check columns, quoting the identifiers where necessary.
- name: replica
in: query
schema:
type: string
enum:
- default
- all
description: |-
Modifies the data sent in update and delete change messages.
When `replica=default` (the default) only changed columns are
included in the `value` of an update message and only the primary
keys are sent for a delete.
When set to `full` the entire row will be sent for updates and
deletes.
# Headers
- name: If-None-Match
in: header
Expand Down

0 comments on commit 4d6bab8

Please sign in to comment.