madapas
11/13/2023, 11:11 AMteam and employee. The team has a "member" relation with employee. Our goal is to read relationships for a specific resource, where the relation is "member," essentially fetching all employees that are members of a particular team.
We've crafted a function utilizing the SpiceDb API to read relationships. The function, responsible for reading existing relationships, follows these steps:
- Defining an ObjectReference for the entity using the v1.ObjectReference.create method.
- Creating a ReadRelationshipsRequest specifying details about the relationship to be read. It includes the ObjectReference and sets the relation to "member"
- gRPC Invoking client.readRelationships method with the defined readRelationshipsRequest.
Currently, we get the error: "Cannot read properties of undefined (reading 'create')."
Is there any documentation available on the correct procedure for this, or do you have suggestions on where I might be going wrong? It's worth mentioning that I'm working with Node.js. Thank you!vroldanbet
11/13/2023, 11:18 AMTOUCH instead of CREATE in WriteRelationships?madapas
11/13/2023, 1:25 PMRelationshipUpdate_Operation.TOUCH works like a charm!! 😅 Thanks!
I am still eager to learn more about reading already existing relationships. Do you have any best practices on how to achieve that?vroldanbet
11/13/2023, 1:39 PMteam
- optional_resource_id: <the_id_of_the_team>
- optional_relation: member
- optional_subject_filter: {
subject_type: employee
}