3 ms·
Somewhere in the middle is best for me. Not quite ORM, not quite raw SQL, but a query builder. In the Node world knexjs.org fits the bill.
by syntheticcdo 7y ago
Somewhere in the middle is best for me. Not quite ORM, not quite raw SQL, but a query builder.
In the Node world knexjs.org fits the bill.
- frosted-flakes 7y agoI agree with that sentiment. Concatenating strings is miserable and error-prone, especially for highly dynamic queries. But there's still another step between a full-blown ORM and a query builder, where you still define the models and the relations between them, but fall back to a plain query builder for constructing queries. That way, you're not dealing with plain arrays, etc., but you're still essentially writing SQL. Like Objection.js[0], which is built on Knex. [0] https://vincit.github.io/objection.js/ https://vincit.github.io/objection.js/
- simplify 7y agoWhat's wrong with working with plain arrays? Genuine question, they seem to work fine for me so far.
- hebrox 7y agoShameless plug: if you're using TypeScript, checkout https://www.npmjs.com/package/@wwwouter/typed-knex https://www.npmjs.com/package/@wwwouter/typed-knex I love Knex, but was missing the type safety, so I created a TypeScript wrapper around it. If you look at the code, you can see I started out as a C# developer :) It's being used in production for a few projects, but it would be great if more people started using it. Feedback is more than welcome!