Hello, I have a use case where I need to call a fu...
# orm-help
c
Hello, I have a use case where I need to call a function in an Upsert call, but only if that upsert creates a new entry in the database. Is there any callback method inside the Upsert properties or any method I can use?
t
Copy code
const result = await prisma.model.upsert({
    where: {
        id: model.id
    },
    update: {},
    create: {}
})


if (result.id !== model.id) { // if inserted
    doStuff()
}
👍 1
r
Yes and the above can be run in a transaction.