I've come to the conclusion that ORMs are good for simple queries like User.find_by(email: "john@snow.com"), but once you get beyond that you are better off just writing sql.
It might be because I'm not used to SQL, but I've found the opposite. Writing a large query with lots of conditions (eg, if the user is signed in, hiding content they've blocked) is miserable without an ORM that can build the query and map the results. I don't like ORMs for lots of reasons but I find them a necessary evil. How do you deal with that in plain SQL, when a query can look completely different depending on…
Show HN: Node.js ORM to query SQL database through an array-like API
41–50 of 108 posts
Re: Show HN: Node.js ORM to query SQL database through an array-like API
#42[flagged]
Re: Show HN: Node.js ORM to query SQL database through an array-like API
#43Cool project! Looking at the docs, for example the pg connector, I couldn't easily find information about how it parameterizes the queries built through method chaining. For example, if I run .filter(user => user.name.eq(unsanitizedInput)) I am presuming that the unsanitizedInput will be put into a parameter? For me, using ORMs on a team that may include juniors, that is one of the key things an ORM provides: the abi…
Re: Show HN: Node.js ORM to query SQL database through an array-like API
#44[flagged]
Yes, in my opinion the biggest problem with straight SQL is dynamic filters. It easily becomes a huge mess and that filter is only good for that one query, sure you can layer on stuff to make it better, but then you might as well use a library.
WHERE (name LIKE :name OR :name IS NULL)
AND (city = :city OR :city IS NULL)
AND ...
By no means it is perfect, but can save you from writing many different queries for different filters while being easy to optimize by db (:name and :city are known before query execution).Still, I prefer explicit SQL in webservices/microservices/etc. the code and its logic is "irrelevant" - we care only about external effects: database content, result of a db query, calls to external services (db can be considered to be nothing more than an external service). And it's easier to understand what's going on when there is one less layer of abstraction (orm)
Re: Show HN: Node.js ORM to query SQL database through an array-like API
#45It is dope, please continue on this. I used to work with TypeORM and really missed using EntityFramework. That actually led me to switch to Mongo (Mongoose). I'm really looking forward to this project!
Re: Show HN: Node.js ORM to query SQL database through an array-like API
#46Re: Show HN: Node.js ORM to query SQL database through an array-like API
#47Very cool. Reminds me of linq to sql
Re: Show HN: Node.js ORM to query SQL database through an array-like API
#48I've come to the conclusion that ORMs are good for simple queries like User.find_by(email: "john@snow.com"), but once you get beyond that you are better off just writing sql.
It might be because I'm not used to SQL, but I've found the opposite. Writing a large query with lots of conditions (eg, if the user is signed in, hiding content they've blocked) is miserable without an ORM that can build the query and map the results. I don't like ORMs for lots of reasons but I find them a necessary evil. How do you deal with that in plain SQL, when a query can look completely different depending on…
Re: Show HN: Node.js ORM to query SQL database through an array-like API
#49I love your syntax for joins and unions! A bit puzzled by why the connector slots into the query, instead of the query slotting into the connector, given that it’s the connector that’s actually doing the work. I.e. ‘connector.fetch(query)‘ … rather than… ‘query.fetch(connector)‘
It was more of an ergonomics choice. To me it seems like it's more readable to write `await users.filter(user => user.id.eq(42).fetch(connector)` instead of `await connector.fetch(users.filter(user => user.id.eq(42))`. But I might be wrong, your idea makes more sense from logical perspective.
Re: Show HN: Node.js ORM to query SQL database through an array-like API
#50> array-like API why is this arbitrary property desirable?