You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inspired by prisma generator feature. I find it very useful for generating json/types/schemas/validators/trpc/etc. The idea is to have a plugin type function that has access to the underlying orm schema/types with the ability to automatically generate and output code based on that.
Use cases include generating custom CRUD types, various API schema/routes patterns (trpc, openAPI, graphQL), non-zod validators, running complex multi-schema migrations, etc
I guess the main challenge is the entry point fur such function. Prisma includes/requires a convenient generation step for that purpose. In the case of orchid-orm this could be part of the connection configuration and can be conditionally (necessary for production builds) triggered during initialization. The user than installs the package which includes predifined initialization function accepting the schema and handles the rest. Bonus points for compatibility with Prisma generators (not sure how feasible that is).
In terms of syntax it could look like something like this:
orchidORM({
// databaseURL has the following format:
// postgres://user:password@localhost:5432/dbname
//
// ssl option can be specified as a parameter:
// postgres://user:password@localhost:5432/dbname?ssl=true
databaseURL: process.env.DATABASE_URL,
// ssl can also be specified as an option:
ssl: true,
generators: [
{
name: 'orchid-orm-trpc-generator',
config: { ... },
enabled: process.env.MODE === 'development',
}
]
log: true, // option for logging, false by default
autoPreparedStatements: true, // see in query builder setup docs, false by default
noPrimaryKey: 'ignore', // see in query builder setup docs, 'error' by default
}, {
user: UserTable,
message: MessageTable,
})
PS: Let me know, if I am missing something. I have a couple of more features in mind that I shared on reddit. I can follow the above template to create issues for them. OrchidORM looks really promising, I would love to also help with the project, so I will stay in touch once I free up my schedule a bit.
The text was updated successfully, but these errors were encountered:
This sounds very useful and interesting!
I see Prisma has a lot of generators for various frameworks. tRPC is a good starting point.
Making it compatible with Prisma would be a big win because all Prisma generators would work with Orchid.
So many ideas and everything to do, it would be awesome if other people could help.
And of course, create more issues if you have more ideas, sooner or later all will be done.
I didn't use such generators for Prisma before, so had a little naive hope that they will generate code that only depends on a framework, but of course, in reality, generated code highly depends on Prisma.
Use cases include generating custom CRUD types, various API schema/routes patterns (trpc, openAPI, graphQL), non-zod validators, running complex multi-schema migrations, etc
Cannot do everything, but I'll start with on trpc, and sooner or later on a generator for some GraphQL server.
Inspired by prisma generator feature. I find it very useful for generating json/types/schemas/validators/trpc/etc. The idea is to have a plugin type function that has access to the underlying orm schema/types with the ability to automatically generate and output code based on that.
Use cases include generating custom CRUD types, various API schema/routes patterns (trpc, openAPI, graphQL), non-zod validators, running complex multi-schema migrations, etc
I guess the main challenge is the entry point fur such function. Prisma includes/requires a convenient generation step for that purpose. In the case of
orchid-orm
this could be part of the connection configuration and can be conditionally (necessary for production builds) triggered during initialization. The user than installs the package which includes predifined initialization function accepting the schema and handles the rest. Bonus points for compatibility with Prisma generators (not sure how feasible that is).In terms of syntax it could look like something like this:
PS: Let me know, if I am missing something. I have a couple of more features in mind that I shared on reddit. I can follow the above template to create issues for them. OrchidORM looks really promising, I would love to also help with the project, so I will stay in touch once I free up my schedule a bit.
The text was updated successfully, but these errors were encountered: