yourlifeismineagain
01/31/2025, 10:29 AMdefinition app/user {
relation user_id: app/string_value
relation user_source: app/string_value
}
the example [here](https://github.com/authzed/authzed-node/blob/42d202db4d5c3e3a0226c0bd4289df6786fbf72b/examples/v1/example.js) has only one relation. how do i create an entry with more than one relation?
many thanks for the support!! 🙏yourlifeismineagain
01/31/2025, 11:47 AMyetitwo
01/31/2025, 4:57 PMyetitwo
01/31/2025, 4:57 PMyourlifeismineagain
01/31/2025, 10:53 PMasync createUser(user: User): Promise<void> {
console.log('Creating user:', user);
const client = this.getClient();
try {
const request: v1.WriteRelationshipsRequest = {
updates: [
{
operation: v1.RelationshipUpdate_Operation.CREATE,
relationship: {
resource: {
objectType: 'user',
objectId: user.userId.trim(),
},
relation: 'source',
subject: {
object: {
objectType: 'user_source',
objectId: user.userSource.trim(),
},
optionalRelation: '',
},
},
},
],
optionalPreconditions: [],
};
await client.writeRelationships(request, {});
} catch (error) {
throw new SpiceDBError(
`Failed to create user: ${error instanceof Error ? error.message : String(error)}`
);
}
}
yourlifeismineagain
01/31/2025, 10:54 PMdefinition user_source {}
definition user {
relation source: user_source
}
yetitwo
02/01/2025, 4:06 PM