title: For Prisma Client join queries is it possible to move deeply nested fields to top level of result?
body: <p>Does Prisma have the ability to move nested fields from another table join to the top level of the result, like a flattened view? I want to put the result JSON into a frontend table without digging through nested objects and building another object.</p>
  <p>For example I want to replicate this behavior where I can pick and choose the columns from different tables (columns from User, and School). Currently I use a raw query with a similar SQL, however I wonder if it's possible with using only the Prisma API:</p>
  <pre><code>SELECT 
  u.id
  , u.email
  , s.school_name
  FROM &quot;User&quot; AS u
  JOIN &quot;UserSchool&quot; AS us ON us.user_id = u.id
  JOIN &quot;School&quot; AS s ON s.id = us.school_id
  </code></pre>
  <pre><code>id | email              | school_name
  123| student1@email.com | mount high
  
  I want JSON that looks like this:
  {
          &quot;id&quot;: &quot;1&quot;,
          &quot;email&quot;: &quot;student1@email.com&quot;,
          &quot;school_name&quot;: &quot;mount high&quot;,
  }
  </code></pre>
  <p>If I did this in Prisma, I would need to go into several levels of nested objects to get the same column name on another table for e.g. <code>user[user_school][schoo][school_name]</code>. This requires extra work to loop through all my results, extract from the nested object, and build another object. This example isn't too bad, but I have more joins and deeply nested objects for my actual problem (lots of association/lookup tables). I've experimented with the <code>select</code> and <code>include</code> for my joins, but they are structured with the nested JSON.</p>
  <pre><code>users = await prisma.user.findMany({
          include: {
            user_school: {
              include: {
                school: true,
              },
            },
          },
  </code></pre>
  <pre><code>{
          &quot;id&quot;: &quot;1&quot;,
          &quot;email&quot;: &quot;student1@email.com&quot;,
          &quot;user_school&quot;: [
              {
                  &quot;id&quot;: 1,
                  &quot;user_id&quot;: &quot;1&quot;,
                  &quot;school_id&quot;: &quot;1&quot;,
                  &quot;school&quot;: {
                      &quot;id&quot;: 1,
                      &quot;school_name&quot;: &quot;mountain high&quot;,
                  }
              }
          ],
  }
  
  </code></pre>