fdarian / prisma-generator-drizzle

A Prisma generator for generating Drizzle schema with ease
90 stars 10 forks source link

Re-export all the models in the schema file #17

Closed Scalahansolo closed 5 months ago

Scalahansolo commented 5 months ago

I am trying to create an internal package in my codebase that needs access to everything in my schema. Right now all the models are imported to build the schema, but I need access to those types outside of that one file and I don't want to have to seek into the individual files.

Maybe the generated directory should include an index.ts which exports out the schema as well as all the individual models?

fdarian commented 5 months ago

There's currently schema.ts that exports a schema variable which you can use to get all models from one entrypoint. It's also used for relational query

Scalahansolo commented 5 months ago

Yeah, I've been using that. It just feels overly verbose to always have to do prepend my models with schema.XXX but maybe that's just me.

Im guessing I can probably figure something how for myself for now. If down the line this continues to be something I want to improve I'll throw out a PR.

fdarian commented 5 months ago

I personally just use import { users } from ".../users", which is what I would also do if I wrote the schema by myself. I only use the import { schema } from ".../schema" when I initialize drizzle to setup the relational query.