Skip to content

Commit 54628cf

Browse files
authored
Merge pull request #137 from powersync-ja/update-sync-rules-in-readme
Mention bucket priorities on demo readme
2 parents 738fd0a + 7e5acf0 commit 54628cf

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

demos/android-supabase-todolist/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,29 @@ Follow this guide to:
1111
2. Create a new PowerSync instance, connecting to the database of the Supabase project. See instructions [here](https://docs.powersync.com/integration-guides/supabase-+-powersync#connect-powersync-to-your-supabase).
1212
3. Deploy sync rules.
1313

14+
### Opting in to priorities
15+
16+
If you want to use the example with [bucket priorities](https://docs.powersync.com/usage/use-case-examples/prioritized-sync),
17+
you can adopt the following sync rules instead of the ones suggested by the simpler integration guide:
18+
19+
```YAML
20+
bucket_definitions:
21+
all_lists:
22+
priority: 1
23+
parameters: select request.user_id() as "user"
24+
data:
25+
- select * from lists where owner_id = bucket."user"
26+
27+
list_items:
28+
# Separate bucket per list
29+
parameters: select id as list_id from lists where owner_id = request.user_id()
30+
data:
31+
- select * from todos where list_id = bucket.list_id
32+
```
33+
34+
The project will work with both sync rules, but giving lists a higher priority allows updates to be synchronized before
35+
all items have been received.
36+
1437
## Configure project in Android Studio
1538
1639
1. Clone this repo: ```git clone https://github.com/powersync-ja/powersync-kotlin.git```

demos/supabase-todolist/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,29 @@ To setup your environment, please consult [these instructions](https://www.jetbr
1313

1414
A step-by-step guide on Supabase<>PowerSync integration is available [here](https://docs.powersync.com/integration-guides/supabase).
1515

16+
### Opting in to priorities
17+
18+
If you want to use the example with [bucket priorities](https://docs.powersync.com/usage/use-case-examples/prioritized-sync),
19+
you can adopt the following sync rules instead of the ones suggested by the simpler integration guide:
20+
21+
```YAML
22+
bucket_definitions:
23+
all_lists:
24+
priority: 1
25+
parameters: select request.user_id() as "user"
26+
data:
27+
- select * from lists where owner_id = bucket."user"
28+
29+
list_items:
30+
# Separate bucket per list
31+
parameters: select id as list_id from lists where owner_id = request.user_id()
32+
data:
33+
- select * from todos where list_id = bucket.list_id
34+
```
35+
36+
The project will work with both sync rules, but giving lists a higher priority allows updates to be synchronized before
37+
all items have been received.
38+
1639
## Configure project in Android Studio
1740
1841
1. Clone this repo: ```git clone https://github.com/powersync-ja/powersync-kotlin.git```

0 commit comments

Comments
 (0)