-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
195 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/integrations/drivers/server/node.md → ...grations/drivers/server/better-sqlite3.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
title: PGlite | ||
--- | ||
|
||
ElectricSQL supports [Node.js](https://nodejs.org) server application using using [PGlite](https://github.com/electric-sql/pglite/), our lightweight WebAssembly build of Postgres. | ||
|
||
## Dependencies | ||
|
||
Add `@electric-sql/pglite` as a dependency to your app, e.g.: | ||
|
||
```shell | ||
npm install @electric-sql/pglite | ||
``` | ||
|
||
See the [PGlite repo](https://github.com/electric-sql/pglite/) for more information. | ||
|
||
## Usage | ||
|
||
```tsx | ||
import { electrify } from 'electric-sql/pglite' | ||
import { PGlite } from '@electric-sql/pglite' | ||
|
||
// Import your generated database schema. | ||
import { schema } from './generated/client' | ||
|
||
// Define custom configuration if needed | ||
const config = { | ||
url: 'https://example.com:5133' | ||
} | ||
|
||
// Create the PGlite database connection. The first argument | ||
// is your database name. Changing this will create/use a new | ||
// local database file. | ||
const conn = new PGlite('/path/to/postgres/datadir') | ||
|
||
// Instantiate your electric client. | ||
const electric = await electrify(conn, schema, config) | ||
|
||
// Connect to Electric, passing along your authentication token | ||
// See Usage -> Authentication for more details. | ||
await electric.connect('your token') | ||
``` | ||
|
||
You can now use the client to read, write and sync data, e.g.: | ||
|
||
```tsx | ||
const { db } = electric | ||
|
||
const results = await db.projects.findMany() | ||
console.log(results) | ||
``` | ||
|
||
See <DocPageLink path="usage/data-access" /> and <DocPageLink path="integrations/frontend" /> for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
title: node-postgres | ||
--- | ||
|
||
ElectricSQL supports [Node.js](https://nodejs.org) server application using the [node-postgres](https://node-postgres.com) driver. | ||
|
||
## Dependencies | ||
|
||
Add `pg` as a dependency to your app, e.g.: | ||
|
||
```shell | ||
npm install pg | ||
``` | ||
|
||
## Usage | ||
|
||
```tsx | ||
import pg from 'pg' | ||
import { electrify, ElectricDatabase } from 'electric-sql/node-postgres' | ||
|
||
// Import your generated database schema. | ||
import { schema } from './generated/client' | ||
|
||
// Define custom configuration if needed | ||
const config = { | ||
url: 'https://example.com:5133' | ||
} | ||
|
||
// Create the node-postgres database connection. | ||
const client = new pg.Client({ | ||
// Connection configuration, see: | ||
// https://node-postgres.com/apis/client | ||
}) | ||
await client.connect() | ||
|
||
// Instantiate your electric client. | ||
const conn = ElectricDatabase(client, 'name-of-database') | ||
const electric = await electrify(conn, schema, config) | ||
|
||
// Connect to Electric, passing along your authentication token | ||
// See Usage -> Authentication for more details. | ||
await electric.connect('your token') | ||
``` | ||
|
||
You can now use the client to read, write and sync data, e.g.: | ||
|
||
```tsx | ||
const { db } = electric | ||
|
||
const results = await db.projects.findMany() | ||
console.log(results) | ||
``` | ||
|
||
See <DocPageLink path="usage/data-access" /> and <DocPageLink path="integrations/frontend" /> for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
title: PGlite | ||
--- | ||
|
||
ElectricSQL supports running in the web browser using [PGlite](https://github.com/electric-sql/pglite/), our lightweight WebAssembly build of Postgres that supports in-browser persistence using IndexedDB. | ||
|
||
## Dependencies | ||
|
||
Add `@electric-sql/pglite` as a dependency to your app, e.g.: | ||
|
||
```shell | ||
npm install @electric-sql/pglite | ||
``` | ||
|
||
See the [PGlite repo](https://github.com/electric-sql/pglite/) for more information. | ||
|
||
## Usage | ||
|
||
```tsx | ||
import { electrify } from 'electric-sql/pglite' | ||
import { PGlite } from '@electric-sql/pglite' | ||
|
||
// Import your generated database schema. | ||
import { schema } from './generated/client' | ||
|
||
// Define custom configuration if needed | ||
const config = { | ||
url: 'https://example.com:5133' | ||
} | ||
|
||
// Create the PGlite database connection. The first argument | ||
// is your database name. Changing this will create/use a new | ||
// local database file. | ||
// PGlite uses a `idb://` prefix to specify that the database | ||
// is stored in indexedDB. | ||
const conn = new PGlite('idb://electric.db', { | ||
// You can optionally use the relaxed durability mode to | ||
// improve responsiveness. | ||
// This schedules flush to indexedDB for after a query has | ||
// returned. | ||
relaxedDurability: true, | ||
}) | ||
|
||
// Instantiate your electric client. | ||
const electric = await electrify(conn, schema, config) | ||
|
||
// Connect to Electric, passing along your authentication token | ||
// See Usage -> Authentication for more details. | ||
await electric.connect('your token') | ||
``` | ||
|
||
You can now use the client to read, write and sync data, e.g.: | ||
|
||
```tsx | ||
const { db } = electric | ||
|
||
const results = await db.projects.findMany() | ||
console.log(results) | ||
``` | ||
|
||
See the [examples/web-wa-sqlite](https://github.com/electric-sql/electric/tree/main/examples/web-wa-sqlite) demo app, <DocPageLink path="usage/data-access" /> and <DocPageLink path="integrations/frontend" /> for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.