Skip to content
This repository was archived by the owner on Oct 21, 2020. It is now read-only.

Conversation

schickling
Copy link
Member

@schickling schickling commented Mar 6, 2020

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

@schickling schickling added the process/candidate candidate for the next milestone label Mar 10, 2020
@schickling schickling requested a review from sorenbs March 10, 2020 11:24
@janpio janpio added area/prisma-client-js and removed process/candidate candidate for the next milestone labels Mar 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants