Skip to content

About sync_rules bucket parameters #60

@JCKodel

Description

@JCKodel

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_id

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 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions