Hi everyone, does someone knows why I’m unable to ...
# orm-help
b
Hi everyone, does someone knows why I’m unable to perform a
connectOrCreate
query in a many-to-many (explicit) relation.
Copy code
tags: {
  connectOrCreate: {
    where: { name: 'General' },
    create: { tags: { create: { name: 'General' } } }
  }
}
Many thanks!
For some reason I can only specify the
id
in the
where
, example:
Copy code
tags: {
  connectOrCreate: {
    where: { id: 1 },
    create: { tags: { create: { name: 'General' } } }
  }
}
But if what I want is a
connectOrCreate
I might not have an
id
Here’s my prisma schema:
The main issue here is that I can only make it work if I specify the
id
in the
where
:
As my type autocompletion suggests.
But since the tag may not exist, I don’t know what’s the
id
so what I want is to create or connect a new tag record. It may work only for
connect
but not for
create
or
connectOrCreate
.