Hey everyone! I've recently got an idea from seeing how many people requested this, so here is my proposal.
Design
My aim is to make this system as easy as possible and as such I thought about this feature as a perfect fit for the Experimental tag. To use it, you'd have to add 2 more keys in your configuration file:
As with any experimental feature, you have to add codeSchemas to enable the feature. The codeGenerators array provides a list of relative paths for the config generators.
Code
This is an example of how I thought the code part could work:
model User {
id Int @id @default(autoincrement())
name String @unique
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
title String @unique
userId Int
user User @relation(fields: [userId], references: [id])
}
As you can see, everything you need is under the Constraints object. Some values (like DEFAULT and RELATION in this example) are callable, and the value you provide will be passed as an argument in your schema.
Wrapping Up
Let me know what you think about this proposal and any improvements you'd like to see!
Creating schemas with JavaScript and TypeScript
Hey everyone! I've recently got an idea from seeing how many people requested this, so here is my proposal.
Design
My aim is to make this system as easy as possible and as such I thought about this feature as a perfect fit for the Experimental tag. To use it, you'd have to add 2 more keys in your configuration file:
As with any experimental feature, you have to add
codeSchemas
to enable the feature. ThecodeGenerators
array provides a list of relative paths for the config generators.Code
This is an example of how I thought the code part could work:
This would create the schema:
As you can see, everything you need is under the Constraints object. Some values (like DEFAULT and RELATION in this example) are callable, and the value you provide will be passed as an argument in your schema.
Wrapping Up
Let me know what you think about this proposal and any improvements you'd like to see!