forked from powersync-ja/powersync-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync-rules.yml
36 lines (36 loc) · 1.89 KB
/
sync-rules.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
bucket_definitions:
user:
parameters: select request.user_id() as user_id
data:
- select * from profiles where id = bucket.user_id
- select * from memberships where profile_id = bucket.user_id
- select * from contacts where owner_id = bucket.user_id
- select * from messages where sender_id = bucket.user_id
- select *, '...' as content from messages where recipient_id = bucket.user_id AND messages.sent_at IS NULL
- select * from messages where recipient_id = bucket.user_id AND messages.sent_at IS NOT NULL
- select * from groups where owner_id = bucket.user_id
contacts:
parameters: select profile_id from contacts where owner_id = request.user_id()
data:
- select * from profiles where id = bucket.profile_id
groups:
parameters:
- select id as group_id from groups where owner_id = request.user_id()
- select group_id from memberships where profile_id = request.user_id()
data:
- select * from groups where id = bucket.group_id
- select * from messages where group_id = bucket.group_id AND messages.sent_at IS NOT NULL
- select * from memberships where group_id = bucket.group_id
group_draft_messages:
parameters:
- select id as group_id, owner_id as user_id from groups where owner_id = request.user_id()
- select group_id, profile_id as user_id from memberships where profile_id = request.user_id()
data:
- select * from messages where group_id = bucket.group_id AND sender_id = bucket.user_id AND messages.sent_at IS NULL
chats:
parameters:
- select recipient_id as partner_id from messages where sender_id = request.user_id()
- select sender_id as partner_id from messages where recipient_id = request.user_id()
data:
- select id, id as profile_id from profiles as chats where id = bucket.partner_id
- select * from profiles where id = bucket.partner_id