Re:Show HN: Node.js ORM to query SQL database through an arr...
by tilyupo on Thursday September 05, 2024 @09:57AM
(#41456700)
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 arr...
by jgoyvaerts on Thursday September 05, 2024 @10:54AM
(#41457220)
What about moving the connector to the table declaration, similar to dbcontext in .net?
Something like Q.table(definition, connector), which would then allow you to just write users.filter(user => user.id.eq(42).fetch()
Re:Show HN: Node.js ORM to query SQL database through an arr...
by williamdclt on Friday September 06, 2024 @04:57AM
(#41464282)
I’m not sure I can say which is _objectively_ better, but I was also surprised, connector.fetch would be more consistent with common JS practices
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)‘