Reference/Relations between resources
hi I'd love to add relations between resources in my table
Is it possible with refine?
Im looking for something like <ReferenceField/> in react admin
im using nestjsx/crud as a backend if that helps
3 Replies
Hi @danyalutsevich. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Yes, it is possible to add relations between resources in your table using Refine. Refine provides hooks like
useOne
and useMany
to handle data relations, which allow you to easily display related data in your components. For forms, you can use the useSelect
hook to manage select inputs that fetch data from related resources.
Here's an example of how you can add a category
field to the products
resource using the useSelect
hook:
In this example, the useSelect
hook fetches categories from the categories
resource and populates a select input with these categories.
For more information, you can refer to the useSelect documentation (https://refine.dev/docs/core/hooks/use-select/).
Additionally, since you are using nestjsx/crud
as a backend, you can connect it to Refine using the provided data provider example: NestJs CRUD Data Provider (https://github.com/refinedev/refine/tree/master/examples/data-provider-nestjsx-crud).
For more details on handling relationships in forms, you can check the Refine documentation on forms and relationships (https://refine.dev/docs/guides-concepts/forms/#relationships-).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@447478993101389824> kapa.ai is still learning and improving, please let us know how it did by reacting below
foreign-sapphireOP•5mo ago
i'd love to implement it in list page