Replies: 4 comments
-
You can have multiple Our dashboard should show an error if these sync rules were input there. But we currently don't have linting for self hosted cases. You should be able to achieve your desired result by implementing two bucket definitions: user_data:
parameters:
- SELECT token_parameters.user_id as 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
user_companies:
parameters:
- SELECT company_id FROM company_users WHERE user_id = token_parameters.user_id
data:
- SELECT * FROM companies WHERE id = bucket.company_id |
Beta Was this translation helpful? Give feedback.
-
@stevensJourney Thank you for your response, but one doubt remains: What if
|
Beta Was this translation helpful? Give feedback.
-
It's encouraged to return multiple SQL rows results from The data query: data:
- SELECT * FROM companies WHERE id = bucket.company_id Will be evaluated in each bucket with The user will see all the sync buckets' data. Which will implicitly join the data. |
Beta Was this translation helpful? Give feedback.
-
@stevensJourney Thank you very much. Now it's crystal clear. |
Beta Was this translation helpful? Give feedback.
-
My scenario: I have a
users
table, acompanies
table and acompany_users
table where I add users to companies.My sync_rules.yaml is:
Problem 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 thecompany_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
Beta Was this translation helpful? Give feedback.
All reactions