Skip to content

Commit 67c5a06

Browse files
committed
Documentation edits made through Mintlify web editor
1 parent 7b5c60f commit 67c5a06

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

usage/sync-rules/organize-data-into-buckets.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Each user can sync a number of buckets (up to 1,000), and each bucket defines a
99
This is defined using two queries:
1010

1111
1. Select bucket parameters from a user ID and/or other parameters ([parameter queries](/usage/sync-rules/parameter-queries))
12+
1213
2. Select data in the bucket using the bucket parameters ([data queries](/usage/sync-rules/data-queries))
1314

1415
When designing your buckets, it is recommended, but not required, to group all data in a bucket where the same parameters apply.
@@ -17,7 +18,7 @@ An example:
1718

1819
```yaml
1920
bucket_definitions:
20-
user_buckets:
21+
user_lists:
2122
# Select parameters for the bucket, using the current user_id
2223
# (request.user_id() comes from the JWT token)
2324
parameters: SELECT request.user_id() as user_id
@@ -28,4 +29,4 @@ bucket_definitions:
2829
2930
<Info>
3031
**Note**: Table names within Sync Rules must match the names defined in the [client-side schema](/installation/client-side-setup/define-your-schema).
31-
</Info>
32+
</Info>

usage/sync-rules/parameter-queries.mdx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ Parameter queries allow parameters to be defined on a bucket to group data. Thes
77
```yaml
88
bucket_definitions:
99
# Bucket Name
10-
user_buckets:
10+
user_lists:
1111
# Parameter Query
1212
parameters: SELECT request.user_id() as user_id
1313
# Data Query
1414
data:
1515
- SELECT * FROM lists WHERE lists.owner_id = bucket.user_id
1616

17-
user_table_buckets:
17+
user_lists_table:
1818
# Similar query, but using a table
1919
# Access can instantly be revoked by deleting the user row/document
2020
parameters: SELECT id as user_id FROM users WHERE users.id = request.user_id()
@@ -25,7 +25,9 @@ bucket_definitions:
2525
Available functions in sync rules are:
2626
2727
1. `request.user_id()`: Returns the JWT subject, same as `request.jwt() ->> 'sub'`
28+
2829
2. `request.jwt()`: Returns the entire (signed) JWT payload as a JSON string.
30+
2931
3. `request.parameters()`: Returns [client parameters](/usage/sync-rules/advanced-topics/client-parameters) as a JSON string.
3032

3133
Example usage:
@@ -63,16 +65,21 @@ request.jwt() ->> 'app_metadata.custom_field' -- custom field added by a service
6365
The new functions available in sync rules are:
6466
6567
1. `request.jwt()`: Returns the entire (signed) JWT payload as a JSON string.
68+
6669
2. `request.parameters()`: Returns [client parameters](/usage/sync-rules/advanced-topics/client-parameters) as a JSON string.
70+
6771
3. `request.user_id()`: Returns the token subject, same as `request.jwt() ->> 'sub'` and also the same as `token_parameters.user_id` in the previous syntax.
6872

6973
The major difference from the previous `token_parameters` is that all payloads are preserved as-is, which can make usage a little more intuitive. This also includes JWT payload fields that were not previously accessible.
7074

7175
Migrating to the new syntax:
7276

7377
1. `token_parameters.user_id` references can simply be updated to `request.user_id()`
78+
7479
2. Custom parameters can be updated from `token_parameters.my_custom_field` to `request.jwt() ->> 'parameters.my_custom_field'`
80+
7581
1. This example applies if you keep your existing custom JWT as is.
82+
7683
2. Supabase users can now make use of [Supabase's standard JWT structure](https://supabase.com/docs/guides/auth/jwts#jwts-in-supabase) and reference `app_metadata.my_custom_field` directly.
7784

7885
Example:
@@ -210,6 +217,9 @@ The supported SQL is based on a small subset of the SQL standard syntax.
210217
Notable features and restrictions:
211218

212219
1. Only simple `SELECT` statements are supported.
220+
213221
2. No `JOIN`, `GROUP BY` or other aggregation, `ORDER BY`, `LIMIT`, or subqueries are supported.
222+
214223
3. For token parameters, only `=` operators are supported, and `IN` to a limited extent.
224+
215225
4. A limited set of operators and functions are supported — see [Operators and Functions](/usage/sync-rules/operators-and-functions).

0 commit comments

Comments
 (0)