specs
specs copied to clipboard
Prisma Client JS: Shortcut syntax for @id / @@id
This Prisma Client JS change introduces an API shortcut syntax when referencing single-field @id fields and multi-field @@id fields.
// before
const user = await prisma.user.findOne({ where: { id: 42 } })
const newPost = await prisma.post.create({
data: {
title: 'Hello',
author: { connect: { id: 42 } },
},
})
// after (before still works)
const user = await prisma.user.findOne({ where: 42 })
const newPost = await prisma.post.create({
data: {
title: 'Hello',
author: { connect: 42 },
},
})
This applies to:
-
findOne({ where: ... }) - Nested write operations with
{ connect: ... } - Pagination