-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Description
My scenario: I have a users table, a companies table and a company_users table where I add users to companies.
My sync_rules.yaml is:
bucket_definitions:
user_data:
parameters:
- SELECT token_parameters.user_id as user_id
- SELECT company_id FROM company_users WHERE user_id = token_parameters.user_id
data:
- SELECT * FROM users WHERE id = bucket.user_id
- SELECT * FROM user_settings WHERE user_id = bucket.user_id
- SELECT * FROM company_users WHERE user_id = bucket.user_id
- SELECT * FROM companies WHERE owner_id = bucket.user_id or id = bucket.company_idProblem is: a user can be in more than one company, so SELECT company_id FROM company_users WHERE user_id = JWT can return more than one result.
Given the bucket data fetches all companies where id equals the company_id above, it will return all companies, only the first, the whole thing will fail?
If this requires an IN where clause, how it can be written?
Documentation is very vague in sync_rules regard =\
Thanks in advance
Metadata
Metadata
Assignees
Labels
No labels