How add sub key on query
Okay I have this query :
Basically the key of this query is
What is the best way to do it ? Thx !
const {
data: playlist,
refetch,
} = useQuery({
queryKey: playlistKeys.detail(Number(params.playlist)),
queryFn: async () => {
if (!params.playlist || !params.lang) throw new Error('No playlist id or locale');
const { data } = await supabase
.from('playlist')
.select(`
*,
user(*),
items:playlist_item(
*,
movie(*)
),
guests:playlist_guest(
*,
user:user(*)
)
`)
.eq('id', params.playlist)
.order('rank', { ascending: true, referencedTable: 'playlist_item' })
.returns<Playlist[]>()
.single();
return data;
},
enabled: !!params.playlist && !!params.lang,
});const {
data: playlist,
refetch,
} = useQuery({
queryKey: playlistKeys.detail(Number(params.playlist)),
queryFn: async () => {
if (!params.playlist || !params.lang) throw new Error('No playlist id or locale');
const { data } = await supabase
.from('playlist')
.select(`
*,
user(*),
items:playlist_item(
*,
movie(*)
),
guests:playlist_guest(
*,
user:user(*)
)
`)
.eq('id', params.playlist)
.order('rank', { ascending: true, referencedTable: 'playlist_item' })
.returns<Playlist[]>()
.single();
return data;
},
enabled: !!params.playlist && !!params.lang,
});Basically the key of this query is
['playlist', id]['playlist', id]. My question is how to add sub key for itemsitems and guestsguests like this :['playlist', id, 'items']
['playlist', id, 'guests']['playlist', id, 'items']
['playlist', id, 'guests']What is the best way to do it ? Thx !