Unable to link a field to table via Xata SDK (JS/TS)
hello, I have been trying to link a
role
field in one table to a record in the roles
table via the Xata SDK, but it does not seem to work. For more context, I am trying to create a new user and the role
field is a link to the roles
table. In the schema definition, the role
cannot be null, but console.log
ing the return value from db.users.create
returns the created user without the link under the role
field.
I have tried manually passing in the ID to the role I want to link, but that returns Fig. 1 and the new user record is not created
If I try to pass the actual value I want from the roles table i.e. roles.role
e.g. being == 'user', the create command is successful but users.role
is still null. see Fig.2.
I have also tried querying the DB for the role I want, and then passing it as value for users.role
, if I pass the full object i.e, userRole
, or userRole.xata_id
I get the error in Fig.1 if I pass the UserRole.role
I get the error from Fig.2
I am using a Postgres-enabled workspace and Dedicated clusters1 Reply
Hi @Kaligraphy , thanks for reaching out. Let me take a look and see if I can shed some light on what's going on.
I've not been able to recreate this issue in my own environment. I created two simple tables with a link and I was able to create a record passing the target record id as a string.
which returns...
Have you since deleted the users and roles table? If so, please recreate the tables as you did before so I can take a look at them via support access. Also, if you could share the create statements you used, that would be helpful.
Feel free to DM me if anything contains sensitive info or contact me via [email protected]