Assigning specific data to a user

Hi I have a mysql database which I connected in DSF.
In my database I have a table called “companies” and also another table called “users”. Each company has it’s own id. The ‘users’ table links to the “companies” table by a related table called “company_id”. My question is how would I set a user to access specific data for it’s own company and info? For example I can do a GET request using table/ table name = “companies” and then put the id in the string. This obviously is one way to do it but I’m wondering if there’s away where the user can control the data accessed? I came across “Look up keys” under user role but I’m not too sure how I would use those in this scenario. Can anyone give me any direction?

Not sure I understand your use case exactly, but it sounds like you want your users to only have access to their specific data.

You can use lookup keys for this. Lookup keys can be assigned to users or roles, and if a user has a lookup by the same name as a role lookup, the user lookup takes precedence.

Set up your lookup by giving it a name, for example: my_company_id, and a value – the value of the company_id that corresponds to this user or role.

Then in the role access settings, add an advanced filter to _table/companies, where company_id = {my_company_id} (see screenshot)

Hi thank you for your response. Would this scenario require for me to make a look up key for each company?
Since in lookup keys I’m giving it a value it seems I would need to make a look up key for each one. Please let me know if this is correct. Thank you!

That’s correct. You will need to specify the value of the lookup for each company