4 ms·
How does it compare to zapatos? https://jawj.github.io/zapatos/ https://jawj.github.io/zapatos/
by paraph1n 3y ago
How does it compare to zapatos?
https://jawj.github.io/zapatos/ https://jawj.github.io/zapatos/
- lf-non 3y agoWe moved away from zapatos because the generated types are good only when selecting from single table. The moment we start selecting some subset of columns from a join of multiple tables, it is upto the developer to provide the right combination of pick and intersection of generated types and type safety takes a hit. The solution we use right now is ts-sql-query [1] which supports automatic type-safety for complex joins, CTEs, subselects etc. I evaluated Kysely as well but found the sql feature set coverage of ts-sql-query better at the time. I maintain a code-generator [2] for this project that can generate the table mappers from database schema similar to how zapatos. We don't have as good support for lateral joins and deriving json from database though, which zapatos does really well. [1] https://ts-sql-query.readthedocs.io/ https://ts-sql-query.readthedocs.io/ [2] https://github.com/lorefnon/ts-sql-codegen https://github.com/lorefnon/ts-sql-codegen
- httgp 3y agoHow does this compare with pgTyped[1]? [1] https://github.com/adelsz/pgtyped https://github.com/adelsz/pgtyped
- lf-non 3y agoI like pgtyped - when the queries are mostly static it is a great solution. Solutions like ts-sql-query are better when you need to dynamically generate complex sql. With ts-sql-query it is very easy to create sql select statements where multiple individual where clauses, or even joins are conditional based on the incoming filters. You can choose to use stored procedures etc. for the more complex cases while keeping pgtyped for 80% of the less dynamic use cases. We decided not to go that route to keep most of the application in typescript which we are more comfortable with.
- igalklebanov 3y ago> which supports automatic type-safety for complex joins, CTEs, subselects etc. I evaluated Kysely as well but found the sql feature set coverage of ts-sql-query better at the time. Kysely also provides "automatic type-safety for complex joins, CTEs, subselects etc.". Gotta love how toxic some open-source maintainers are, bashing other libraries while self-promoting.
- igalklebanov 3y agoI'd suggest you try them both, and pick what you like better or what feels safer to bet on for your project. I know some of our users use both, zapatos for codegen and kysely for querying.