Change id column name for useOne to anything other than "id"
This seems like such an easy question to answer, but after hours of searching through the docs and already asked questions on Discord I give up and post this here.
I'm using useOne to get data from a resource like this
My issue is that the column containing the user id in table "users" is not called "id" in the database but "user_id". How can I make sure useOne uses "users.user_id" as column to check for the id and not "users.id". Right now I'm receiving the error
because of course the column users.id doesn't exist
3 Replies
Hi @fuss132. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
You can use the
meta
property to match the column name of the primary key in your data table to the column name you have assigned. In your case, you can pass the id
parameter to the meta
property to change the column name to user_id
.
Here's how you can do it:
Now, it will search for users in the user_id
column of the data table instead of id
column.
For more information, you can refer to the documentation (https://refine.dev/docs/packages/documentation/data-providers/supabase/).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@178960777435283456> kapa.ai is still learning and improving, please let us know how it did by reacting below
solid-orangeOP•17mo ago
Yes! That's it. Many thanks to the AI 😄