Can't findOne, update, delete on composite primary keys #488
Comments
Note: Reproduce again. |
I can't reproduce this with |
Introspecting a Postgres DB that has the above SQL generates this schema: model variables {
email String
key String
name String
value String
@@id([name, key])
} Afterwards the following import { PrismaClient } from '@prisma/client'
const client = new PrismaClient()
client.variables.create({ data: { name: 'a', key: 'b', email: 'mail@example.org', value: 'foo' } }).then(res => { console.log('create', res) })
client.variables.findOne({ where: { name_key: { key: 'b', name: 'a' } } }).then(res => { console.log('findOne', res) })
client.variables.update({ where: { name_key: { key: 'b', name: 'a' } }, data: { value: 'bar' } }).then(res => { console.log('update', res) })
client.variables.delete({ where: { name_key: { key: 'b', name: 'a' } } }).then(res => { console.log('delete', res) }) (prisma2@2.0.0-alpha.934) Can you please confirm that this is the wanted behavior @matthewmueller? |
Can I request that composite keys be documented in the find/update/delete sections of the docs (or even a separate section that gives a hint how it works)? I was stuck on them for days and didn't think they worked properly because the schema was showing my where options as including something like Thanks to @janpio 's post, above, now I see how it works and I'm unstuck. Documentation of this point would have saved a tremendous amount of time. |
Hey @dpankros 👋 yes, I just created an issue in the |
Related: #489
The text was updated successfully, but these errors were encountered: