I have two tables in Supabase, one called places which stores just basic information of the place such as name etc. The other called places_information which stores addresses and other details.
A place could have many addresses such as a franchise so it has a one to many relationship, with a custom id field being created in places_information that is linked to the main id in the places table
I have made dummy data where two addresses have been made linked to one place
Code
await supabase.from('places').select('''*,
places_information (*)''').execute().then((value) {
if (value.error != null) {
context.showSnackBar(message: 'Places dont exist');
} else {
log(value.data[0].toString());
}
});
Using the code above returns the following output
{
"id":4,
"name":"Just a name",
"description":"This is a description",
"cuisine":"Steakhouse",
"places_information":[
{
"id":1,
"place_id":4,
"street_address":"test data",
"city":"another place",
},
{
"id":4,
"place_id":4,
"street_address":"second data",
"city":"second place",
}
]
}
Where as i just want
{
"id":4,
"name":"Just a name",
"description":"This is a description",
"cuisine":"Steakhouse",
"places_information":[
{
"id":1,
"place_id":4,
"street_address":"test data",
"city":"another place",
}
]
},
{
"id":4,
"name":"Just a name",
"description":"This is a description",
"cuisine":"Steakhouse",
"places_information":[
{
"id":4,
"place_id":4,
"street_address":"second data",
"city":"second place",
}
]
}