Please share your feedback about the preview feature uncheckedScalarInputs that was released in v2.11.0 in this issue.
- If you encounter a bug, please open a bug report in this repo.
- If the feature is working well for you, please share this in a comment below or leave a 👍 on this issue.
If you have any questions, don't hesitate to ask them in the #prisma2 channel in the Prisma Slack.
Set foreign keys directly with uncheckedScalarInputs (Preview)
We now support writing foreign keys (also known as relation scalars) directly with the uncheckedScalarInputs preview feature.
Consider this sample Prisma schema:
generator client {
provider = "prisma-client-js"
previewFeatures = ["uncheckedScalarInputs"]
}
model User {
id Int @id @default(autoincrement())
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
authorId Int
author User @relation(fields: [authorId], references: [id])
}
Instead of using connect when creating a new Post record to wire up a relation with a User record, you can now directly set the authorId value:
await prisma.post.create({
data: {
// You can now set the foreign key directly...
authorId: 1,
// ... or connect the relationship...
// author: {
// connect: {
// id: 1
// }
// }
// ... but not both at the same time
},
});
Please share your feedback about the preview feature
uncheckedScalarInputsthat was released in v2.11.0 in this issue.If you have any questions, don't hesitate to ask them in the
#prisma2channel in the Prisma Slack.Set foreign keys directly with uncheckedScalarInputs (Preview)
We now support writing foreign keys (also known as relation scalars) directly with the
uncheckedScalarInputspreview feature.Consider this sample Prisma schema:
Instead of using
connectwhen creating a newPostrecord to wire up a relation with aUserrecord, you can now directly set theauthorIdvalue: