Reputation: 409
I want to get the parameters interest.name, interest.description, interest.category.name as String with the value that is currently returning a list. They are translations and I select the value depending the code with the code .eq('...',languageCode)
that I show below
Is there a way to do this in supabase?
this is my json at the moment:
{
"id":"f36686d7-f815-4372-aba8-4d3f7fe1a4a5",
"member_id":"c2579821-54e4-42c8-8b35-b522a34712a2",
"interest_id":"yoga",
"interest":{
"id":"yoga",
"name":[
{
"name":"Yoga",
}
],
"active":true,
"category":{
"id":"fitness",
"icon":"meditation",
"name":[
{
"name":"Fitness"
}
],
"color":"primary200",
"active":true,
},
"category_id":"fitness",
"description":[
{
"description":"Physical activity focused on poses and meditation."
},
{
"description":"Actividad física basada en posturas y meditación."
}
],
"interest_type_id":"fitness"
}
}
This is the code of the query:
var query = _supabaseClient.from('member_interests').select('''
*,
interest:interest_id(
*,
category:category_id(
*,
name: category_translations(name)
),
name: interest_translations(name),
description: interest_translations(description)
)
''').eq('member_id', memberId);
if (languageCode != null) {
query = query.eq(
'interest.interest_translations.language_code',
languageCode,
);
query = query.eq(
'interest.category.category_translations.language_code',
languageCode,
);
}
final data = await query;
return data.map(MemberInterest.fromJson).toList();
}
Upvotes: 1
Views: 30