prisma-type-generator
v1.6.0
Published
Prisma type generator
Downloads
854
Maintainers
Readme
Prisma Type Generator
Prisma type generator is a package that generates the type and interface that are available in your schema.
Installation
npm install prisma-type-generator
Usage
generator types {
provider = "prisma-type-generator"
}
// output = "path"
Example
generator client {
provider = "prisma-client-js"
}
generator types {
provider = "prisma-generator-types"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @unique @default(uuid())
name String
username String
Profile Profile[]
}
enum UserType {
pro
best
}
model Profile {
id String @unique @default(uuid())
contact Int
user User @relation(fields: [userId], references: [id])
userId String
}
Generates
npx prisma generate
It will generate the following file, prisma/types/index.ts with the following code
export interface User {
id: string;
name: string;
username: string;
}
export interface Profile {
id: string;
contact: number;
userId: string;
}
export const UserType = { pro: "pro", best: "best" } as const;
export type UserType = (typeof UserType)[keyof typeof UserType];
Contributing
If you'd like to contribute, please follow our contribution guidelines.
Support
If you like the project, please consider supporting us by giving a ⭐️ on Github.
Bugs
If you find a bug, please file an issue on our issue tracker on GitHub
License
prisma-fns is open-source software licensed under the MIT license.