genetic-orange
genetic-orange13mo ago

Change resource primary key

Is there a way to change a resource's primary key property? For example I have a resource which its PK is key istead of id. Or all of this should be handled through DataProvider?
5 Replies
kapa.ai
kapa.ai13mo ago
Hi @nickwoods. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
kapa.ai
kapa.ai13mo ago
---------------------- Yes, you can change a resource's primary key property by using the meta property when working with hooks like useMany. In the meta property, you can pass the idColumnName parameter to specify the column name of the primary key if it's different from the default "id". Here's an example:
useMany({
resource: "posts",
ids: [1, 2],
meta: {
idColumnName: "key",
},
});
useMany({
resource: "posts",
ids: [1, 2],
meta: {
idColumnName: "key",
},
});
In this example, the primary key column is changed to "key" instead of the default "id". This will be used when searching for the ids in the data table. For more information, refer to the Supabase documentation (https://refine.dev/docs/packages/documentation/data-providers/supabase) on using meta to pass values to the data provider. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
Supabase | refine
Introduction
kapa.ai
kapa.ai13mo ago
<@567279564028510208> kapa.ai is still learning and improving, please let us how it did by reacting below
skilled-lime
skilled-lime13mo ago
Yes, You need to customize your data provider to support that
genetic-orange
genetic-orange13mo ago
thx you, I will also try the good bot response idColumnName seems to do the job. Nice