
BookShelf, Simple ORM for Node - squiggy22
https://github.com/tgriesser/bookshelf
======
bpicolo
My biggest problem with bookshelf is that it automatically grabs column names,
so you don't (by default) have any representation in code of what the dang
model looks like. Since JS is not typed, this can lead to a lot of having no
idea what might be going on unless you wrote the code yourself

~~~
vectorpush
On the other hand, this behavior is quite nice if you want to quickly build
something around an existing database and you don't really want to spend time
reenumerating the entire schema in code before being able to leverage the ORM.

~~~
tracker1
Honestly, if I know what the database looks like, I'd rather use babel with
string templates for building parameterized queries against the database
directly. [1] [2]

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](https://github.com/felixfbecker/node-sql-template-strings)

[2] [https://github.com/tracker1/mssql-ng](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.

~~~
vectorpush
I actually agree with you and find that writing queries directly gives better
performance, is much easier to debug, makes it easier to integrate more
advanced database features (like stored procedures or non-standard features
like postgres schemas or the jsonb data-type), and avoids the configuration
overhead that some ORMs require. In fact, I chose bookshelf precisely because
I didn't have to do anything except supply the table name and start CRUDing
whereas I'd normally just start writing raw queries in a situation where my
goal was to start talking to the database ASAP.

------
HNcow
Bookshelf isn't bad - but also make sure to check out knex, which Bookshelf is
build on top of. Knex is a great Dapper like micro ORM/query builder if you'd
just rather do most of your work in SQL.

------
statenjason
Good to see that it's using knex for queries. Many node ORMs dumb every
database down to a Mongo-like object hash.

~~~
cwmma
knex is by the same guy, who wrote it expressly for bookshelf

------
untog
I was battling with Sequelize JS for a long time, then discovered Bookshelf. A
breath of fresh air, it works so much better. Plus, the underlying library
(Knex) is also fantastic for raw queries, migrations, etc.

~~~
scandox
I'm also curious what your problems were. I'm using it at present and haven't
run into anything worrying... _yet_

~~~
untog
I didn't have _problems_ as such with Sequelize, it was just a lot more
difficult to work with than Bookshelf. And it's been about two years so I
don't remember the details, sorry.

------
Xantier
For end to end usage samples and somewhat comparing to other DBs I can
recommend my kitchen-sink project NERD-stack:
[https://github.com/Xantier/nerd-stack](https://github.com/Xantier/nerd-stack)

------
setheron
When I used this back in the day, it was frustrating that the exceptions
thrown by BookShelf would be a mismatch of: ValidationErrors, BookShelf
errors, database specific errors.

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.

------
tuananh
Can someone help me with this?

[http://stackoverflow.com/questions/32777559/how-to-
join-3-ta...](http://stackoverflow.com/questions/32777559/how-to-
join-3-tables-with-bookshelf-in-node-js)

------
lsdafjklsd
I think it's the best ORM for Node. That said it makes me really miss Active
Record, which is just... _sigh_ the best.

------
steveklabnik
I've really only used bookshelf in a pretty basic way, but I've been happy
with it.

