Hi,
I’m having real trouble understanding how the predicate works within the Roles system.
I have an index of doctors that are linked to a company: doctors_by_company.
All the doctor and the company documents have a reference back to their owner the person who created them - the logged in user.
The doctors_by_company index is expecting a company ref as its only term.
Because both the doctor and the company have a ref to the logged in user (owner), I thought I would be able to do something like the below to create the predicate as part of the privileges section.
Here, I am checking the logged in user matches the owner of the company the doctor belongs to.
Lambda(
"company",
Equals(
Select(["data", "owner"], Get(Var("company"))),
CurrentIdentity()
)
)
My frontend query sent through the JS client looks like this:
I know the rest of the Role is ok because changing the predicate to the below works:
Lambda(
"company",
true
)
I just can’t work out how to retrieve the company based on the terms given to the predicate.
Hope someone can point me in the right direction.
Thanks.