Live data from Hacker News

Show HN: Node.js ORM to query SQL database through an array-like API

github.com

101–108 of 108 posts

Re: Show HN: Node.js ORM to query SQL database through an array-like API

#101
post #58

Now that we have about 15 years of ORMs, do they really make things easier? SQL is not a difficult language to learn, and views and stored procedures provide a stable interface that decouples the underlying table schema, allowing for migrations and refactoring of the database structure without having to rewrite a lot of code. ORMs seem to me to be mostly about syntactic sugar nowadays; I’m worried that the abstractio…

It might depend on the ORM and the time to lightbulb on the differences between them and the relevance if any to the project at hand.

Re: Show HN: Node.js ORM to query SQL database through an array-like API

#102
post #58

Now that we have about 15 years of ORMs, do they really make things easier? SQL is not a difficult language to learn, and views and stored procedures provide a stable interface that decouples the underlying table schema, allowing for migrations and refactoring of the database structure without having to rewrite a lot of code. ORMs seem to me to be mostly about syntactic sugar nowadays; I’m worried that the abstractio…

> I’m worried that the abstractions that they set up insulate the developer from the reality of the system they’re depending on

except for the the simplest of queries, I always check my ORM based queries by looking at the translated SQL. This seems like common sense to me, but maybe not.

Re: Show HN: Node.js ORM to query SQL database through an array-like API

#103
post #71

My take on this is that it's not always the best idea to abstract-out SQL. You see, the SQL itself is too valuable abstraction, and also a very "wide" one. Any attempt to hide it behind another abstraction layer will face these problems: - need to learn secondary API which still doesn't cover the whole scope of SQL - abstraction which is guaranteed to leak, because any time you'll need to optimize - you'll need to st…

The author of slonik, a great (IMO) tool for composing queries in raw SQL in Node for Postgres, has a good blog post explaining this same general idea: https://gajus.medium.com/stop-using-knex-js-and-earn-30-bf41...

The way I've always put it is "ORMs make the easy stuff a bit easier, and the harder stuff way harder." Just learn SQL, it's not that hard and it's a much better, transferable skill.

Re: Show HN: Node.js ORM to query SQL database through an array-like API

#104
post #71

My take on this is that it's not always the best idea to abstract-out SQL. You see, the SQL itself is too valuable abstraction, and also a very "wide" one. Any attempt to hide it behind another abstraction layer will face these problems: - need to learn secondary API which still doesn't cover the whole scope of SQL - abstraction which is guaranteed to leak, because any time you'll need to optimize - you'll need to st…

Yes this applies to a lot of abstractions of SQL, this one (inspired by Entity Framework/Linq) however works _with_ the grain by more or less by finding a sweet-spot between the SQL and the source language and most importantly doesn't try to hide the SQL.

My experience with Linq over the years has been great, only time I've needed to go raw SQL was to supply index hints (you can add that to Linq but we opted not to) and doing special things with merge statements. But EF allows you do submit raw SQL queries where needed.

The important part is, when you have a good system that actually provides benefits(Linq is properly typed) and doesn't get in the way or produce weird SQL then it'll work out.

I've only needed to use around 10 raw SQL queries where Linq failed to hundreds or maybe thousands of Linq queries where it worked perfectly well and this includes some fairly heavy queries.

Re: Show HN: Node.js ORM to query SQL database through an array-like API

#106
It looks like this isn't really an ORM, it's more like a node-based layer to simplify DB access.

Which I actually like more, because I want to understand the database, not abstract it away. But dealing with SQL is/can be awkward. This library means I don't have to dynamically build sql queries in code.

Handy!

Re: Show HN: Node.js ORM to query SQL database through an array-like API

#107
Why are we trying so hard to pretend the database is something else?

I've had more success modelling database concepts directly in the language; tables, columns, keys, indexes, queries, records etc.

https://github.com/codr7/hostr/tree/main/src/Hostr/DB

Post reply on HN