is there an alternative for this kind of code (gra...
# orm-help
i
is there an alternative for this kind of code (grabbing the id of the embedded doc (which have no directly exposed crud methods))?:
Copy code
const subscription = await db
      .updateSubscription({
        data: {
          playlists: {
            update: {
              sections:{
                create:{
                  name,
                },
              },
            },
          },
        },
        where: { id: subscription_id },
      })
      .$fragment(graphql`
        {
          id
          playlists {
            sections {
              id
              name
              # updatedAt
            }
          }
        }
      `)
  )
  
  const { id } = find(subscription.playlists.sections, ({ name: name_ })=> name_ === name)
  // orderBy(subscription.playlists.sections, 'updatedAt', 'desc')[0]
h
Yes, currently you have to do this for embedded docs but it will change soon with the select api we will introduce: https://github.com/prisma/rfcs/blob/new-ts-client-rfc/text/0000-new-ts-client.md
👍 1