Bartosz Borycki
06/21/2022, 6:26 AMmodel User {
id String @id @unique @default(cuid())
user String @unique
email String @unique
first_name String?
last_name String?
skills Skills[]
...
}
model Skills {
id String @id @unique @default(cuid())
can_play User[]
type SkillsList
}
When I try to "register user" i want to connect new user with Skills... Here is my code for create user right now:
const result = await prisma.user.create({
data: {
user: user,
email: email,
password: password,
first_name: first_name,
last_name: last_name,
skills: {
connectOrCreate: skills.map((id: string) => ({
where: { id: id },
})),
},
},
});
Skills is passing in string array with ID of skill, but I've got error:
Unknown arg `where` in data.skills.connect.0.where for type SkillsWhereUniqueInput. Did you mean `id`? Available args:
type SkillsWhereUniqueInput {
id?: String
}
Anyone can help me with this?Bartosz Borycki
06/21/2022, 6:38 AMskills: {
connect: skills.map((skill_id: string) => {
return { id: skill_id };
}),
},
And it works perfectly 😄Nurul
06/22/2022, 12:52 PMconnectOrCreate
you need to have where
and create
attributes both, it seems you just passed where
which would have caused the issue. connect
worked as you passed the unique field id
through which records will be connected.