4 ms·
I really hope the community converges on just one common solution to this as I see soo many different approaches to the same “there’s no great modular ORM for t
by seer 4y ago
I really hope the community converges on just one common solution to this as I see soo many different approaches to the same “there’s no great modular ORM for typescript” problem.
I myself went the route of “lets just have raw sql queries” but extract distinct and specific types from them automatically- https://github.com/ivank/potygen https://github.com/ivank/potygen
Great thing is that it handles sql of any complexity - CTEs, views, nested selects/joins/unions/custom functions you name it. All tools you can use to encapsulate logic in sql itself (what ORM were supposed to be for) and then have it be statically validated at compile time thus saving you the need for righting all those trivial unit tests that was also one of the key benefits of ORMs.
Admittedly if there was something like LINQ I would probably not have ventured into building potygen, but I’m glad I did as I learned so much about SQL as a language and what it had to offer - its silly how much logic I used to rely on writing in code that could easily be handled by sql in a much mode concise way.
- kristiandupont 4y agoThat looks very neat! I use libpg_query to parse view definitions to create type information from there, but it's quite basic so far. Are you doing something similar, or did you implement the parser from scratch?
- seer 4y agoI started the project mostly as a way to play around recursive decent parsers, and then it actually turned into a useful tool. So yeah its all pure JS, and not produced from a parser generator.
- kristiandupont 4y agoThat's impressive! I will try to see if and how I can incorporate your tool into my workflow.
- sally_glance 4y agoLooks nice and I appreciate the README - those comparison tables are much more elaborate than my sibling comment, though looking at the single con in the table for potygen itself does make me wonder if they might be a little biased ;-)