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
2 changes: 1 addition & 1 deletion architecture/client-architecture.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The local SQLite database embedded in the PowerSync SDK is automatically kept in

#### Writing Data

Client-side data modifications, namely updates, deletes and inserts, are persisted in the embedded SQLite database as well as stored in an upload queue. The upload queue is a blocking [FIFO](https://en.wikipedia.org/wiki/FIFO%5F%28computing%5Fand%5Felectronics%29) queue that gets processed when network connectivity is available.
Client-side data modifications, namely updates, deletes and inserts, are persisted in the embedded SQLite database as well as stored in an upload queue. The upload queue is a blocking [FIFO](https://en.wikipedia.org/wiki/FIFO_%28computing_and_electronics%29) queue that gets processed when network connectivity is available.

Each entry in the queue is processed by writing the entry to your existing backend application API, using a function [defined by you](/installation/client-side-setup/integrating-with-your-backend) (the developer). This is to ensure that existing backend business logic is honored when uploading data changes. For more information, see the section on [integrating with your backend](/installation/client-side-setup/integrating-with-your-backend).

Expand Down
6 changes: 3 additions & 3 deletions client-sdk-references/flutter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ The most commonly used CRUD functions to interact with your SQLite data are:

### Fetching a Single Item

The [get](https://pub.dev/documentation/powersync/latest/sqlite%5Fasync/SqliteQueries/get.html) method executes a read-only (SELECT) query and returns a single result. It throws an exception if no result is found. Use [getOptional](https://pub.dev/documentation/powersync/latest/sqlite%5Fasync/SqliteQueries/getOptional.html) to return a single optional result (returns `null` if no result is found).
The [get](https://pub.dev/documentation/powersync/latest/sqlite_async/SqliteQueries/get.html) method executes a read-only (SELECT) query and returns a single result. It throws an exception if no result is found. Use [getOptional](https://pub.dev/documentation/powersync/latest/sqlite_async/SqliteQueries/getOptional.html) to return a single optional result (returns `null` if no result is found).

```dart
// Find a list item by ID
Expand All @@ -203,7 +203,7 @@ Future<TodoList> find(id) async {

### Querying Items (PowerSync.getAll)

The [getAll](https://pub.dev/documentation/powersync/latest/sqlite%5Fasync/SqliteQueries/getAll.html) method returns a set of rows from a table.
The [getAll](https://pub.dev/documentation/powersync/latest/sqlite_async/SqliteQueries/getAll.html) method returns a set of rows from a table.

```dart
/// Get all list IDs
Expand All @@ -215,7 +215,7 @@ Future<List<String>> getLists() async {
```
### Watching Queries (PowerSync.watch)

The [watch](https://pub.dev/documentation/powersync/latest/sqlite%5Fasync/SqliteQueries/watch.html) method executes a read query whenever a change to a dependent table is made.
The [watch](https://pub.dev/documentation/powersync/latest/sqlite_async/SqliteQueries/watch.html) method executes a read query whenever a change to a dependent table is made.

```dart
StreamBuilder(
Expand Down
2 changes: 1 addition & 1 deletion client-sdk-references/flutter/flutter-orm-support.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ORM support is available via the following package (currently in an alpha releas
<Card
title="drift_sqlite_async | Dart package"
icon="dart-lang"
href="https://pub.dev/packages/drift%5Fsqlite%5Fasync"
href="https://pub.dev/packages/drift_sqlite_async"
horizontal
/>

Expand Down
6 changes: 3 additions & 3 deletions client-sdk-references/flutter/usage-examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: "Code snippets and guidelines for common scenarios"

Read and write transactions present a context where multiple changes can be made then finally committed to the DB or rolled back. This ensures that either all the changes get persisted, or no change is made to the DB (in the case of a rollback or exception).

The [writeTransaction(callback)](https://pub.dev/documentation/powersync/latest/sqlite%5Fasync/SqliteQueries/writeTransaction.html) method combines all writes into a single transaction, only committing to persistent storage once.
The [writeTransaction(callback)](https://pub.dev/documentation/powersync/latest/sqlite_async/SqliteQueries/writeTransaction.html) method combines all writes into a single transaction, only committing to persistent storage once.

```dart
deleteList(SqliteDatabase db, String id) async {
Expand All @@ -20,11 +20,11 @@ deleteList(SqliteDatabase db, String id) async {
}
```

Also see [readTransaction(callback)](https://pub.dev/documentation/powersync/latest/sqlite%5Fasync/SqliteQueries/readTransaction.html) .
Also see [readTransaction(callback)](https://pub.dev/documentation/powersync/latest/sqlite_async/SqliteQueries/readTransaction.html) .

## Subscribe to changes in data

Use [watch](https://pub.dev/documentation/powersync/latest/sqlite%5Fasync/SqliteQueries/watch.html) to watch for changes to the dependent tables of any SQL query.
Use [watch](https://pub.dev/documentation/powersync/latest/sqlite_async/SqliteQueries/watch.html) to watch for changes to the dependent tables of any SQL query.

```dart
StreamBuilder(
Expand Down
2 changes: 1 addition & 1 deletion installation/authentication-setup/firebase-auth.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mode: wide

Configure authentication on the PowerSync instance with the following settings:

* JWKS URI: [https://www.googleapis.com/service\_accounts/v1/jwk/[email protected]](https://www.googleapis.com/service%5Faccounts/v1/jwk/[email protected])
* JWKS URI: [https://www.googleapis.com/service\_accounts/v1/jwk/[email protected]](https://www.googleapis.com/service_accounts/v1/jwk/[email protected])
* JWT Audience: Firebase project ID

Firebase signs these tokens using RS256.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: "PowerSync is compatible with both Consumer and B2B SaaS Stytch pro

## Consumer Authentication

See this community project for detailed setup instructions: [https://github.com/guillempuche/localfirst\_react\_server](https://github.com/guillempuche/localfirst%5Freact%5Fserver)
See this community project for detailed setup instructions: [https://github.com/guillempuche/localfirst\_react\_server](https://github.com/guillempuche/localfirst_react_server)

## B2B SaaS Authentication

Expand Down
2 changes: 1 addition & 1 deletion installation/database-connection.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Select your Postgres hosting provider for steps to connect your Postgres databas
```
</Accordion>
<Accordion title="AWS RDS">
1. [Locate the connection details from RDS](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER%5FConnectToPostgreSQLInstance.html):
1. [Locate the connection details from RDS](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToPostgreSQLInstance.html):
* Copy the **"Endpoint"** value.
* Paste the endpoint into the "**Host**" field.
* Complete the remaining fields: "**Name**", "**Host**", "**Port**", "**Database name**", "**Username**", "**Password**" and "**SSL Mode"** are required. You can paste a connection string into the "**URI**" field to simplify this.
Expand Down
2 changes: 1 addition & 1 deletion integration-guides/flutterflow-+-powersync.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ For once, a blank screen means success:
1. Click on **"Custom Code" -> "Add" -> "Action".**
2. Name the Custom Action `initpowersync`.
1. **NOTE:** use all lowercase for this Custom Action is important due to naming conversion that FF performs behind the scenes.
3. Copy and paste the custom action code from here:[https://github.com/powersync-ja/powersync-flutterflow-template/blob/flutterflow/lib/custom\_code/actions/initpowersync.dart](https://github.com/powersync-ja/powersync-flutterflow-template/blob/flutterflow/lib/custom%5Fcode/actions/initpowersync.dart)
3. Copy and paste the custom action code from here:[https://github.com/powersync-ja/powersync-flutterflow-template/blob/flutterflow/lib/custom\_code/actions/initpowersync.dart](https://github.com/powersync-ja/powersync-flutterflow-template/blob/flutterflow/lib/custom_code/actions/initpowersync.dart)
4. Import your schema:
1. On the PowerSync Dashboard, right-click on your instance and select **"Generate Client-Side Schema"** and select Dart as the language.
<Frame>
Expand Down
2 changes: 1 addition & 1 deletion integration-guides/railway-+-powersync.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Find the PowerSync template on the Railway Marketplace, or click below:
<Card
title="Deploy on Railway"
icon="train"
href="https://railway.app/template/RfZi6y?referralCode=2vw%5FV9"
href="https://railway.app/template/RfZi6y?referralCode=2vw_V9"
horizontal
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The following improvements can be considered for this implementation.

## <Icon icon="flutter"iconType="solid" size="24"/> Flutter Example

Our Flutter [To-Do List example app](https://github.com/powersync-ja/powersync.dart/tree/master/demos/supabase-todolist) showcases how to sync attachments (such as photos) using our [powersync\_attachments\_helper](https://pub.dev/packages/powersync%5Fattachments%5Fhelper) package for Flutter.
Our Flutter [To-Do List example app](https://github.com/powersync-ja/powersync.dart/tree/master/demos/supabase-todolist) showcases how to sync attachments (such as photos) using our [powersync\_attachments\_helper](https://pub.dev/packages/powersync_attachments_helper) package for Flutter.

## See Also

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ When the SDK is offline, the streaming stops, but automatically resumes when con
Example implementations of `watch()` can be found below

* [React Native example](https://github.com/powersync-ja/powersync-js/blob/92384f75ec95c64ee843e2bb7635a16ca4142945/demos/django-react-native-todolist/library/stores/ListStore.ts#L5)
* [Flutter example](https://github.com/powersync-ja/powersync.dart/blob/master/demos/supabase-todolist/lib/models/todo%5Flist.dart#L46)
* [Flutter example](https://github.com/powersync-ja/powersync.dart/blob/master/demos/supabase-todolist/lib/models/todo_list.dart#L46)
2 changes: 1 addition & 1 deletion resources/demo-apps-example-projects.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ For example implementations and details of common use cases, see [Use Case Examp
### JavaScript & TypeScript

* Effect + Kysely + Stytch
* [https://github.com/guillempuche/localfirst\_react\_server](https://github.com/guillempuche/localfirst%5Freact%5Fserver)
* [https://github.com/guillempuche/localfirst\_react\_server](https://github.com/guillempuche/localfirst_react_server)
* Tauri + Shadcn UI
* [https://github.com/romatallinn/powersync-tauri](https://github.com/romatallinn/powersync-tauri)
* Expo Web
Expand Down
2 changes: 1 addition & 1 deletion self-hosting/installation/client-side-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ For more details, see [Supabase Auth](/installation/authentication-setup/supabas

Under `client_auth` in your config file, add your Firebase JWKS URI and audience.

* JWKS URI: [https://www.googleapis.com/service\_accounts/v1/jwk/[email protected]](https://www.googleapis.com/service%5Faccounts/v1/jwk/[email protected])
* JWKS URI: [https://www.googleapis.com/service\_accounts/v1/jwk/[email protected]](https://www.googleapis.com/service_accounts/v1/jwk/[email protected])

* JWT Audience: Your Firebase project ID

Expand Down
2 changes: 1 addition & 1 deletion usage/lifecycle-maintenance/compacting-buckets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ One approach is to have regular partial defragmentation, using a query such as:
UPDATE lists SET updated_at = now() WHERE updated_at < now() - interval '1 week'
```

This can be performed on a regular schedule such as every hour or every day, using [pg\_cron](https://github.com/citusdata/pg%5Fcron) or backend-level scheduled tasks.
This can be performed on a regular schedule such as every hour or every day, using [pg\_cron](https://github.com/citusdata/pg_cron) or backend-level scheduled tasks.

The above example will cause clients to re-sync each row once a week, while preventing the number of operations from growing indefinitely. Depending on how often rows in the bucket are modified, the interval can be increased or decreased.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The schema as supplied on the client is only a view on top of the schemaless dat

3. Casting between types should never error, but it may not fully represent the original data. For example, casting an arbitrary string to `INTEGER` will likely result in a "0" value.

4. Full rules for casting between types are described [in the SQLite documentation here](https://www.sqlite.org/lang%5Fexpr.html#castexpr).
4. Full rules for casting between types are described [in the SQLite documentation here](https://www.sqlite.org/lang_expr.html#castexpr).

4. Removing a table/collection is handled on the client as if the table exists with no data.

Expand Down
2 changes: 1 addition & 1 deletion usage/use-case-examples/attachments-files.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ We currently have these helper packages available to manage attachments:
| SDK | Attachments Helper Package | Example Implementation |
| ----------------------------- | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| **React Native / JavaScript** | [powersync-attachments](https://www.npmjs.com/package/@powersync/attachments) | [To-Do List example app](https://github.com/powersync-ja/powersync-js/tree/main/demos/react-native-supabase-todolist) |
| **Flutter** | [powersync\_attachments\_helper](https://pub.dev/packages/powersync%5Fattachments%5Fhelper) | [To-Do List example app](https://github.com/powersync-ja/powersync.dart/tree/master/demos/supabase-todolist) |
| **Flutter** | [powersync\_attachments\_helper](https://pub.dev/packages/powersync_attachments_helper) | [To-Do List example app](https://github.com/powersync-ja/powersync.dart/tree/master/demos/supabase-todolist) |

The example implementations above use [Supabase Storage](https://supabase.com/docs/guides/storage) as storage provider. For more information on the use of Supabase as storage provider, refer to:

Expand Down
2 changes: 1 addition & 1 deletion usage/use-case-examples/crdts.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "CRDTs"
description: "While PowerSync does not use [CRDTs](https://en.wikipedia.org/wiki/Conflict-free%5Freplicated%5Fdata%5Ftype) directly as part of its sync or conflict resolution process, CRDT data (from a library such as [Yjs](https://github.com/yjs/yjs) or y-crdt) may be persisted and synced using PowerSync."
description: "While PowerSync does not use [CRDTs](https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type) directly as part of its sync or conflict resolution process, CRDT data (from a library such as [Yjs](https://github.com/yjs/yjs) or y-crdt) may be persisted and synced using PowerSync."
---

This may be useful for cases such as document editing, where last-write-wins is not sufficient for conflict resolution. PowerSync becomes the provider for CRDT data — both for local storage and for propagating changes to other clients.
Expand Down
12 changes: 6 additions & 6 deletions usage/use-case-examples/full-text-search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This requires creating a separate FTS5 table(s) to index the data, and updating
Currently, FTS is supported in:

* **Flutter:** [powersync.dart](https://github.com/powersync-ja/powersync.dart) ([PowerSync Flutter SDK](/client-sdk-references/flutter))
* Relies on the [sqlite\_async](https://pub.dev/documentation/sqlite%5Fasync/latest/) package for migrations
* Relies on the [sqlite\_async](https://pub.dev/documentation/sqlite_async/latest/) package for migrations
* **Web:** [powersync-sdk-web](https://github.com/powersync-ja/powersync-js/blob/main/packages/web/README.md) ([JavaScript Web SDK](/client-sdk-references/javascript-web))
* Requires version 0.5.0 or greater of the SDK (incl. version 0.2.0 of the [wa-sqlite](https://github.com/powersync-ja/wa-sqlite) package)

Expand Down Expand Up @@ -48,7 +48,7 @@ Future<void> openDatabase() async {
}
```

Note: The Web implementation does not use migrations. It creates the FTS tables separately in [utils/fts\_setup.ts](https://github.com/powersync-ja/powersync-js/blob/main/demos/react-supabase-todolist/src/app/utils/fts%5Fsetup.ts).
Note: The Web implementation does not use migrations. It creates the FTS tables separately in [utils/fts\_setup.ts](https://github.com/powersync-ja/powersync-js/blob/main/demos/react-supabase-todolist/src/app/utils/fts_setup.ts).

**TypeScript example:**

Expand All @@ -66,9 +66,9 @@ SystemProvider = ({ children }: { children: React.ReactNode }) => {

First, we need to set up the FTS tables to match the `lists` and `todos` tables already created in this demo app. Don't worry if you already have data in the tables, as it will be copied into the new FTS tables.

To simplify implementation these examples make use of SQLite migrations. The migrations are run in [migrations/fts\_setup.dart](https://github.com/powersync-ja/powersync.dart/blob/master/demos/supabase-todolist/lib/migrations/fts%5Fsetup.dart) in the Flutter implementation. Here we use the [sqlite\_async](https://pub.dev/documentation/sqlite%5Fasync/latest/) Dart package to generate the migrations.
To simplify implementation these examples make use of SQLite migrations. The migrations are run in [migrations/fts\_setup.dart](https://github.com/powersync-ja/powersync.dart/blob/master/demos/supabase-todolist/lib/migrations/fts_setup.dart) in the Flutter implementation. Here we use the [sqlite\_async](https://pub.dev/documentation/sqlite_async/latest/) Dart package to generate the migrations.

The FTS tables are created in [utils/fts\_setup.ts](https://github.com/powersync-ja/powersync-js/blob/main/demos/react-supabase-todolist/src/app/utils/fts%5Fsetup.ts) in the Web implementation.
The FTS tables are created in [utils/fts\_setup.ts](https://github.com/powersync-ja/powersync-js/blob/main/demos/react-supabase-todolist/src/app/utils/fts_setup.ts) in the Web implementation.

**Dart example:**

Expand Down Expand Up @@ -181,11 +181,11 @@ Clicking on the search icon will open a search bar which will allow you to searc
<img src="/images/usage-7.png"/>
</Frame>

It uses a custom search delegate widget found in [widgets/fts\_search\_delegate.dart](https://github.com/powersync-ja/powersync.dart/blob/master/demos/supabase-todolist/lib/widgets/fts%5Fsearch%5Fdelegate.dart) (Flutter) and [widgets/SearchBarWidget.tsx](https://github.com/powersync-ja/powersync-js/blob/main/demos/react-supabase-todolist/src/components/widgets/SearchBarWidget.tsx) (Web) to display the search results.
It uses a custom search delegate widget found in [widgets/fts\_search\_delegate.dart](https://github.com/powersync-ja/powersync.dart/blob/master/demos/supabase-todolist/lib/widgets/fts_search_delegate.dart) (Flutter) and [widgets/SearchBarWidget.tsx](https://github.com/powersync-ja/powersync-js/blob/main/demos/react-supabase-todolist/src/components/widgets/SearchBarWidget.tsx) (Web) to display the search results.

### FTS Helper

We added a helper in [lib/fts\_helpers.dart](https://github.com/powersync-ja/powersync.dart/blob/master/demos/supabase-todolist/lib/fts%5Fhelpers.dart) (Flutter) and [utils/fts\_helpers](https://github.com/powersync-ja/powersync-js/blob/main/demos/react-supabase-todolist/src/app/utils/fts%5Fhelpers.ts)[.ts](https://github.com/powersync-ja/powersync-js/blob/main/demos/react-supabase-todolist/src/app/utils/fts%5Fhelpers.ts) (Web) that allows you to add additional search functionality which can be found in the [SQLite FTS5 extension](https://www.sqlite.org/fts5.html) documentation.
We added a helper in [lib/fts\_helpers.dart](https://github.com/powersync-ja/powersync.dart/blob/master/demos/supabase-todolist/lib/fts_helpers.dart) (Flutter) and [utils/fts\_helpers](https://github.com/powersync-ja/powersync-js/blob/main/demos/react-supabase-todolist/src/app/utils/fts_helpers.ts)[.ts](https://github.com/powersync-ja/powersync-js/blob/main/demos/react-supabase-todolist/src/app/utils/fts_helpers.ts) (Web) that allows you to add additional search functionality which can be found in the [SQLite FTS5 extension](https://www.sqlite.org/fts5.html) documentation.

**Dart example:**

Expand Down
Loading
Loading