5 ms·
I'm just about to start working on DB layer for our app with TypeScript. Any other alternatives to prisma you guys prefer and why?
by ponyous 5y ago
I'm just about to start working on DB layer for our app with TypeScript. Any other alternatives to prisma you guys prefer and why?
- eydwales 5y agoI suggest to not add a layer. Stay close of the SQL request, you can simply have a function that will fulfill an access pattern. No need for ORM.
- ponyous 5y agoYeah, I have no problem with minimum ORM (prepared statements type of thing) - That's why I am asking the question, Prisma seems a bit too much. Usually I just use simple ORM helpers (get by primary key for example) and anything complex is raw sql. What I am looking for is ideally something that helps with type saftey and seeds/migrations/schema creation.
- topicseed 5y agoTry Knex!
- domlebo70 5y agohttps://github.com/gajus/slonik https://github.com/gajus/slonik
- heisenbit 5y agoI'm wondering at the moment whether Knex (solid query builder and migration) and Objection.js would not do this trick. That combo seems to give me json validation which is nice and seemingly both a way to handle entities and graphs in an efficient way.
- gmac 5y agohttps://jawj.github.io/zapatos/ https://jawj.github.io/zapatos/ (no built-in migration support, though)
- tekkk 5y agoI have been using Flyway with Node.js. Works all right and you write everything (migrations, schema, seeds) in SQL. It does make working with SQL quite straightforward and non-magical. The thing is of course that with very complex queries you'll end up making quite intricate string building stuff which may not be very pretty. I myself am curious to find out if Prisma can make that part go away.
- kapv89 5y agoTypeORM or MikroORM, any of those should be fine
- nikolasburk 5y agoHey, Nikolas from Prisma here. There are quite a few other ORMs for working with DBs in TypeScript (none of them providing the same type-safety guarantees that Prisma does though [1]). In fact, we laid them out on a docs page [2] in case you want to learn which tool might be appropriate for your use case. [1] https://www.prisma.io/docs/concepts/more/comparisons/prisma-and-typeorm#type-safety https://www.prisma.io/docs/concepts/more/comparisons/prisma-... [2] https://www.prisma.io/docs/concepts/overview/should-you-use-prisma https://www.prisma.io/docs/concepts/overview/should-you-use-...
- ponyous 5y agoThanks, that's really useful.
- williamdclt 5y ago(haven't tried Prisma) TypeORM -> classic ORM, the "default" choice in node, but not very mature compared to what exists in Java or things like Django ORM. In my experience it's not an amazing lib, transaction management is a bit painful, I've seen a couple bugs happen. Knex -> it works but not sure why you'd use that rather than TypeORM MikroORM -> not a lot of experience, one of my colleagues really likes it, read the principles behind it and see if that talks to you as it's a bit opinionated Slonik -> Never used it but probably what I'd set up on a new project. Like many people I think that query builders are BS and I'd rather use SQL: Slonik makes that very easy while giving you the usual getOne/getMany utilities I'd like to try Prisma though, I've heard good things
- presentation 5y agoTypeORM is poorly maintained (the lead author had a breakdown and appears to be inactive, and failed to delegate ownership to others), and is riddled with bad abstractions, poor design choices and an enormous pile of game-breaking bugs that make the TypeScript types unsafe and it’s usage clunky and dangerous. I would absolutely use knex, which works, over TypeORM, which routinely doesn’t.
- hardwaresofton 5y agoInteresting -- I actually haven't had as many problems as you have with TypeORM -- it's just mostly worked. Then again, maybe I'm a rare case, because I basically ignore the ORM side and use a little repository pattern, the query builder, and write my own migrations in SQL (as in all the migrations are `await queryRunner.query(...);`). It's been excellent for me -- I ignore the bad abstractions, have a good underlying database (postgres), and drop down to parametrized raw SQL whenever I need to, it's held up extraordinarily well I think. Could you expand on some specific issues/frustrations? Just curious about the side I'm clearly not seeing.
- sickcodebruh 5y agoThis is the one upside I’ve had of using TypeORM: I find its query abstractions so unreliable and surprising that it’s forced me to get better at SQL!
- sorenbs 5y agoThere are many discussions on reddit about Prisma vs TypeORM in particular. For example here: https://www.reddit.com/r/node/comments/l3xu6w/is_prisma_a_viable_alternative_for_typeorm/ https://www.reddit.com/r/node/comments/l3xu6w/is_prisma_a_vi... There is also a good discussion going on here: https://www.reddit.com/r/node/comments/l00fit/what_do_you_think_about_orms/ https://www.reddit.com/r/node/comments/l00fit/what_do_you_th...
- danielskogly 5y agoMy preferred DB layer is Objection.js[0] which is simply an ORM-layer on top of knex[1], with official TypeScript support. [0] https://vincit.github.io/objection.js/ https://vincit.github.io/objection.js/ [1] https://knexjs.org/ https://knexjs.org/
- RivieraKid 5y agoMikroORM. I think it's the best ORM for TypeScript.
- snarkypixel 5y agoI love knex and simply write small functions and roughly keep one file/folder per table. So: user.create(db, { name: .. })
- Seb-C 5y agoIf you want an orm that encourages you to use sql instead of abstracting it, you can look at my library: https://github.com/Seb-C/kiss-orm https://github.com/Seb-C/kiss-orm