In Prisma how do I fetch data as RDBMS join tables resultset in tabular format instead of nested?

15 Views Asked by At

I want to display data in tabular format of two tables. In Prisma I am getting a nested data (Eager). How do I get data in alongside?

Let's say I have user and post tables. I might make mistake in terminology so I am writing in plain SQL.

select user.id, user.full_name, post.title, post.publishedAt from user JOIN post ON (user.id = post.user_id);
id full_name title publishedAt
1 Prashant ORM 01-01-2023
1 Prashant NUXT 02-01-2023
const user = await prisma.user.findMany({
  select: {
    full_name: true,
    id:true
    post: {
      select: {
        title: true,
        publishedAt:true
      },
    },
  },
})
0

There are 0 best solutions below