Is it possible to use `connect` and update the con...
# orm-help
d
Is it possible to use
connect
and update the connecting relation at the same time? Kinda like how you can use
create
to create a new relation.
Copy code
const createPost = await prisma.post.create({
  data: {
    title: "How to make croissants",
    author: {
      create: {
        email: "<mailto:viola@prisma.io|viola@prisma.io>",
        name: "Viola"
      }
    }
  }
})
I kinda want the same, but like...
Copy code
const createPost = await prisma.post.create({
  data: {
    title: "How to make croissants",
    author: {
      connect: {
        id: 10,
        data: {
          email: "<mailto:viola@prisma.io|viola@prisma.io>",
          name: "Viola"
        }
      }
    }
  }
})
I know that exact API is not available, but is there something simlar?
r
@David Ilizarov 👋 This isn’t possible in a single query, but you could use two Prisma queries inside a
transaction
.
d
Ah cool. I made this feature request: https://github.com/prisma/prisma/issues/7787 Not sure if it is simple or difficult for you all to implement, but I think it would be cool to be able to
connectAndUpdate
haha. Similar to
connectOrCreate
.