Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Zapatos, a Postgres Library for TypeScript (jawj.github.io)
28 points by gmac 15 days ago | hide | past | web | favorite | 7 comments



Looks pretty good. Looks like a good compromise between Prisma [1] and pure pg.

Also the way you show examples is one of the best I've seen so far, with the output right below, optionally showing imports imports and the option to show it in a monaco editor with types.

Could you also compare it to Prisma and Mammoth [2]?

[1]: https://www.prisma.io/ [2]: https://github.com/Ff00ff/mammoth


:) Happy that you noticed the thought that went into presenting the examples.

I hadn't come across those other libraries.

On Prisma, I think I agree with your assessment. A key thing that this and Prisma have in common is interrogating your DB to generate types. Zapatos is (almost) wholly limited to generating types, while it seems Prisma generates a bunch of code too.

Prisma seems somewhat more like an ordinary ORM. It introduces more of its own terminology and abstractions, has its own ways of inserting into and querying related tables, and so on. At a glance, it looks nicely thought out. It has plans to become a SaaS of some sort.

Mammoth, on the other hand, looks like it tries to solve a very similar problem to Zapatos, and gets there by providing a query builder. You define all your tables manually in code, and then write SQL through the medium of TypeScript.


I guess this is intentional, but using “shoes” in spanish as a library name does not help google locate mentions of your library.


Fair point!


It does help get a laugh from any fellow spanish speaking dev though..

LOL


How does this compare to TypeORM?


TypeORM is very much a traditional ORM. You define your model classes, and the relationships between them, in code, and TypeORM takes charge of creating and modifying your tables. Then you use the model classes to query the database, without really knowing what SQL is going to be issued. TypeORM is complicated: there are lots of new abstractions to learn, and you’re a long way from the raw SQL.

Zapatos aims at a very much reduced level of abstraction: it’s really just a much more ergonomic, and fully typed, way to run SQL. I created it mainly out of frustration with TypeORM, after converting an existing code base from CoffeeScript to TypeScript and from Sequelize to TypeORM.

My recollection is that TypeORM did something really dumb and unexpected, like deciding to catch a unique index violation and silently replace the offending record, and that this was what finally prompted me to decide to replace it with something homegrown. I also found using transactions with TypeORM clumsy and painful.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: