Skip to content

Preview feature feedback: uncheckedScalarInputs #4209

@matthewmueller

Description

@matthewmueller

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
  },
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions