Skip to content

Commit

Permalink
docs: update shape definitions to use new params key. (#2098)
Browse files Browse the repository at this point in the history
Missed a few places where we need to update the switch to put the shape
definition in the `params` key from
#2081
  • Loading branch information
thruflo authored Dec 4, 2024
1 parent ef90f46 commit 3d64f45
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 13 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ import { useShape } from '@electric-sql/react'
function Component() {
const { data } = useShape({
url: `http://localhost:3000/v1/shape`,
table: `foo`,
where: `title LIKE 'foo%'`,
params: {
table: `foo`,
where: `title LIKE 'foo%'`
}
})

return JSON.stringify(data)
Expand Down
4 changes: 3 additions & 1 deletion examples/remix-basic/app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { matchStream } from "../match-stream"
const itemShape = () => {
return {
url: new URL(`/shape-proxy`, window.location.origin).href,
table: `items`,
params: {
table: `items`,
},
}
}

Expand Down
4 changes: 3 additions & 1 deletion examples/tanstack-example/src/Example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const baseApiUrl = `http://localhost:3001`

const itemShape = () => ({
url: new URL(`/v1/shape`, baseUrl).href,
table: `items`,
params: {
table: `items`,
},
})

async function createItem(newId: string) {
Expand Down
4 changes: 3 additions & 1 deletion website/docs/guides/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ You can then connect your app to Electric [over HTTP](/docs/api/http). Typically
```ts
const stream = new ShapeStream({
url: `https://your-electric-service.example.com/v1/shape`,
table: 'foo'
params: {
table: `foo`
}
})
const shape = new Shape(stream)
```
Expand Down
4 changes: 3 additions & 1 deletion website/docs/guides/shapes.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ import { ShapeStream, Shape } from '@electric-sql/client'

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

Expand Down
4 changes: 3 additions & 1 deletion website/docs/integrations/cloudflare.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export default {

const stream = new ShapeStream({
url: `${ELECTRIC_URL}/v1/shape`,
table: 'routes'
params: {
table: 'routes'
}
})
const shape = new Shape(stream)
const routes = await shape.value
Expand Down
4 changes: 3 additions & 1 deletion website/docs/integrations/expo.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ const ELECTRIC_URL = 'https://my-electric-sync-service.example.com'
export default function HomeScreen() {
const { isLoading, data } = useShape({
url: `${ELECTRIC_URL}/v1/shape`,
table: 'items'
params: {
table: 'items'
}
})

if (isLoading) {
Expand Down
4 changes: 3 additions & 1 deletion website/docs/integrations/netlify.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ const ELECTRIC_URL = process.env.ELECTRIC_URL

const stream = new ShapeStream({
url: `${ELECTRIC_URL}/v1/shape`,
table: 'items'
params: {
table: 'items'
}
})
```

Expand Down
4 changes: 3 additions & 1 deletion website/docs/integrations/supabase.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ import { Shape, ShapeStream } from 'npm:@electric-sql/client'
Deno.serve(async (req) => {
const stream = new ShapeStream({
url: '[YOUR_ELECTRIC_URL]/v1/shape',
table: 'items'
params: {
table: 'items'
}
})
const shape = new Shape(stream)
const items = [...await shape.value]
Expand Down
4 changes: 3 additions & 1 deletion website/docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ import { useShape } from '@electric-sql/react'
function Component() {
const { data } = useShape({
url: `http://localhost:3000/v1/shape`,
table: `foo`
params: {
table: `foo`
}
})
return (
Expand Down
4 changes: 3 additions & 1 deletion website/src/partials/home-cta.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import { useShape } from '@electric-sql/react'
const Component = () => {
const { data } = useShape({
url: `${BASE_URL}/v1/shape`,
table: `items`
params: {
table: `items`
}
})

return (
Expand Down
4 changes: 3 additions & 1 deletion website/use-cases/state-transfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ import { useShape } from '@electric-sql/react'
const Component = () => {
const { data } = useShape({
url: `${BASE_URL}/v1/shape`,
table: `items`
params: {
table: `items`
}
})

return (
Expand Down

0 comments on commit 3d64f45

Please sign in to comment.