authzed-node/examples/v1/example.js at 4...
# spicedb
y
hi there! how are you doing? i have a question concerning the typescript library -- but i think it applies to any library? I wouldl ike to create an entry in spicedb. my schema looks like this
Copy code
definition 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!! 🙏
actually I was looking at the python client and it looks like i'm doing the right thing. keep getting Incorrect arguments passed though :/ any suggestions?
y
what's the actual code you're using?
y
this fails
Copy code
async 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)}`
      );
    }
  }
schema
Copy code
definition user_source {}
definition user {
    relation source: user_source
}
y
and what's the error you're getting?
27 Views