From Prisma Model to Kysely Schema

Hey everyone, I'm using this package https://github.com/valtyr/prisma-kysely, the output of this Prisma Model
model Business {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
email String
name String @db.VarChar(100)
phone String
description String?
bannerUrl String?
address Address @relation(fields: [addressId], references: [id])
addressId String @unique @db.Uuid
workingHours WorkingHours?
services Service[]
businessType BusinessType[]
appointments Appointment[]
user User @relation(fields: [userId], references: [id])
userId String @unique @db.Uuid
}
model Business {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
email String
name String @db.VarChar(100)
phone String
description String?
bannerUrl String?
address Address @relation(fields: [addressId], references: [id])
addressId String @unique @db.Uuid
workingHours WorkingHours?
services Service[]
businessType BusinessType[]
appointments Appointment[]
user User @relation(fields: [userId], references: [id])
userId String @unique @db.Uuid
}
is
export type Business = {
id: Generated<string>;
email: string;
name: string;
phone: string;
description: string | null;
bannerUrl: string | null;
addressId: string;
userId: string;
};
export type Business = {
id: Generated<string>;
email: string;
name: string;
phone: string;
description: string | null;
bannerUrl: string | null;
addressId: string;
userId: string;
};
so when I have Kysely code such as
const business = await db
.insertInto('Business')
.values({
email: `business${i}@example.com`
name: `businessName${i}`,
phone: `phone${i}`,
userId: user[0].id,
addressId: address[0].id,
businessType: businessType[0].id // gives error because it's not in the `schema.d.ts` file
})
.returning('Business.id')
.execute();
const business = await db
.insertInto('Business')
.values({
email: `business${i}@example.com`
name: `businessName${i}`,
phone: `phone${i}`,
userId: user[0].id,
addressId: address[0].id,
businessType: businessType[0].id // gives error because it's not in the `schema.d.ts` file
})
.returning('Business.id')
.execute();
6 Replies
NazCodeland
NazCodeland12mo ago
businessType: businessType[0].id // gives error because it's not in the schema.d.ts file
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Igal
Igal12mo ago
GitHub
Support implicit many-to-many relations · Issue #12 · valtyr/prisma...
It seems Prisma creates a relation table to connect two tables, but prisma-kisely does not create a type for it. I am not sure how the relation table is generated, but it seems to have _{Tab1}On{Ta...
NazCodeland
NazCodeland12mo ago
thank you guys. I think I'm gonna to switch my Prisma schema over to Kysely schema and use the Kysely-codegen package. I really liked my setup of using the Prisma schema because it also allowed me to generate Zod schemas from it. does a package like this:https://github.com/chrishoermann/zod-prisma-typesone exist for Kysely - to - Zod schemas? I googled but no luck
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
NazCodeland
NazCodeland12mo ago
Don't have the skills otherwise I would attempt, maybe one day