BookShelf, Simple ORM for Node
github.com
github.com
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.
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.
This depends on the complexity of your schema. In my case, I was dealing with a 230 table legacy application where some of the tables had as many as 70 columns. I was tasked with building an ad-hoc administrative tool for the owners so that they could perform a few specific tasks and periodically review some information in the system.
I wanted to use an ORM because I didn't want to write a bunch of boilerplate SQL to rig up a tedious but relatively simple internal CRUD app. With that in mind, it certainly didn't make sense to enumerate the details of every column when the alternative (raw SQL) also wouldn't require me to do that. Enumerating explicit column information was unnecessary and certainly would have taken me a lot of time.
He keeps going on about SQL not requiring it, but SQL requires it in every statement (the select clause).
I'd hate to be the one who has to maintain an admin app that could potentially access 230 tables with dynamic column references scattered all throughout the code and no types to keep things in order.
haha a string of SQL is not the same thing as a type constrained data structure.
> I'd hate to be the one who has to maintain an admin app that could potentially access 230 tables with dynamic column references scattered all throughout the code and no types to keep things in order.
Thankfully, the client used a database that is capable of enforcing type constraints automatically, so I didn't have to spend time writing business logic to reiterate what the database already knows and strictly enforces, in a language that can't even enforce type constraints anyway. Re-declaring your column names and types in javascript literally does nothing except waste time. You shouldn't be reading through your application code to understand the schema of your database, especially when you're dealing with hundreds of tables.
It might be a comment on the JavaScript ecosystem but trying to collate all these myriad of exceptions into a single result to show my user was frustrating.
http://stackoverflow.com/questions/32777559/how-to-join-3-ta...