drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
23.49k stars 577 forks source link

Export mapColumnToSchema function #2495

Open MatthewAry opened 3 months ago

MatthewAry commented 3 months ago

I'm trying to create a mechanism to make it easy to write APIs for getting data collections (pagination, sort, filter). I use ElysiaJS and it is able to use Typebox types to validate request data, like query strings. I would like to have this function exported so it can be used to build other tools like the one I'm making. Won't always want to get the whole table. In my case I might want to specify fields that will be used as part of a output produced on a join. Please consider accepting this PR.

matthiasfeist commented 1 month ago

That looks super helpful! Are you planning to adjust the docs as well to document that you can use this exported function in the use-case you describe?

MatthewAry commented 1 month ago

That looks super helpful! Are you planning to adjust the docs as well to document that you can use this exported function in the use-case you describe?

Hahaha, I think the Docs need an overhaul in general. This is because Drizzle's documentation focuses on showing you examples to help guide us to do SQL -> Drizzle function chains, without enumerating the functions that drizzle exposes. Granted this would be very difficult to do, I have not seen any good, auto-generated TS docs yet on any project.

Also, the TypeBox project itself has poor docs too. I would like to connect with a community for TypeBox and solicit feedback from them about how to give examples that are more approachable but right now, I haven't found an active group for this.