Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Honestly, if I know what the database looks like, I'd rather use babel with string templates for building parameterized queries against the database directly. [1] [2]

It seems to me that the layers of ORM (in JS) don't really buy you much more than some simple validation wrappers and a simpler client for SQL queries. After having used a number of ORMs in static environments (mostly C#), I'm much more inclined to prefer a simple SQL client that's easier to make direct SQL queries in than having an ORM in a system that actually complicates things. It'd be one thing if an ORM generated typescript so that you would get auto-complete in your editor/ide, but I don't see much point to this. I'm not a huge fan of typing in JS/TS, but I could at least see the value to some in that case.

[1] https://github.com/felixfbecker/node-sql-template-strings

[2] https://github.com/tracker1/mssql-ng

disclaimer: I wrote mssql-ng and used it for a lot of data migration/manipulation scripts and it was a joy to use with async/await syntax.



I actually agree with you and find that writing queries directly gives better performance, is much easier to debug, makes it easier to integrate more advanced database features (like stored procedures or non-standard features like postgres schemas or the jsonb data-type), and avoids the configuration overhead that some ORMs require. In fact, I chose bookshelf precisely because I didn't have to do anything except supply the table name and start CRUDing whereas I'd normally just start writing raw queries in a situation where my goal was to start talking to the database ASAP.


I agree with you that ORMs don't add a whole lot of value to Node, but I think there's still value in slightly-higher-level libraries.

Like, doing a simple `select whatever from table where x = ? and y = ? and z = ?` is annoying with a string-based query builder when those parameters are optional, sousing something like Knex where you can just pass in a hash of field/value pairs for the criteria for your where clause is a big win.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: