Christian Goebel
09/22/2021, 6:39 PMgroups
in create.groups for type UserUncheckedCreateInput."
which is right, "groups" is not part of "UserUncheckedCreateInput" type, but it is of "UserCreateInput" type.
I searched around on when prisma expects "Unchecked" Input type and when not, but couldn't find any.
Who knows?Ryan
09/23/2021, 5:32 AMChristian Goebel
09/23/2021, 5:39 AMconst admin = await prisma.user.upsert({
where: { email: "<mailto:admin@cgoebel.net|admin@cgoebel.net>" },
update: {},
create: {
email: "<mailto:admin@cgoebel.net|admin@cgoebel.net>",
firstName: "Christian",
lastName: "Goebel",
password: "password",
groups: {
connectOrCreate: {
where: { name: "SuperAdmin" },
create: {
name: "SuperAdmin",
roles: {
where: { name: "backendAdmin" },
create: { name: "backendAdmin" },
},
},
},
},
},
});
Christian Goebel
09/23/2021, 5:40 AMmodel User {
id String @id @default(cuid())
name String?
firstName String?
lastName String?
email String? @unique
password String?
emailVerified DateTime?
image String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
accounts Account[]
sessions Session[]
groups Group[]
roles Role[]
}
model Group {
id Int @id @default(autoincrement())
name String
users User[]
roles Role[]
}
model Role {
id Int @id @default(autoincrement())
name String
users User[]
groups Group[]
}
Ryan
09/23/2021, 5:51 AMconnectOrCreate
for the group
. name
cannot be used in where
as it’s not unique.Christian Goebel
09/23/2021, 11:48 AMRyan
09/23/2021, 11:50 AMname
with id
in the where
argument of connectOrCreate
.Christian Goebel
09/26/2021, 9:59 AMRyan
09/27/2021, 6:27 AM