I am new to Prisma. I have a Postgres data set where the entries include a field named genres
that is an array of strings. I want to call to the database using prisma and return an array of distinct genres. What I want to avoid is treating an array of genres as a distinct value. Example below.
Currently I am calling
<code>const genres = await db.track.findMany({
distinct: ['genres'],
select: { genres: true }
});
</code>
<code>const genres = await db.track.findMany({
distinct: ['genres'],
select: { genres: true }
});
</code>
const genres = await db.track.findMany({
distinct: ['genres'],
select: { genres: true }
});
which is returning
<code>[
{ genres: [ 'house' ] },
{ genres: [ 'techno' ] },
{ genres: [ 'house', 'techno' ] },
]
</code>
<code>[
{ genres: [ 'house' ] },
{ genres: [ 'techno' ] },
{ genres: [ 'house', 'techno' ] },
]
</code>
[
{ genres: [ 'house' ] },
{ genres: [ 'techno' ] },
{ genres: [ 'house', 'techno' ] },
]
Ideally I would like to be getting
[ 'house', 'techno' ]