incredible-moccasinI
Refine2y ago
25 replies
incredible-moccasin

Create & edit a many to many relationship with supabase

Hi, I'm new to Refine and I'm looking for a more elegant way to manage many-to-many relationships with Supabase as my data provider. I've looked at the useMany() example in the documentation, but it seems to focus on one-to-many relationships.

My tables are structured as follows: contacts <-> contact_has_address <-> address

Currently, I'm using multiple useCreate and useCreateMany hooks to create these relationships, but it feels a bit clunky. For example, I first create the address, then I create the contact_has_address record to link both tables. However, editing this setup is proving to be challenging.

Additionally, I need to handle a scenario where a contact can have multiple phone numbers that can be edited, deleted, or added later. This aspect seems a bit tricky based on the documentation I've seen.

I'm curious if there's a more refined approach in Refine to handle these complexities?
Was this page helpful?