Hacker News new | past | comments | ask | show | jobs | submit login

I'm glad to see more alternatives to Sequelize which I'm using. I was just wondering how does Bookshelf compare to Sequelize in terms of maturity and feature set, if anyone here has used both?



I'd actually created Bookshelf after seeing a lack of good support for SQL abstractions in javascript, especially comparison to other languages and frameworks.

In terms of maturity, Bookshelf & Knex are still definitely young and a work in progress, but fairly mature in the sense that they are both heavily inspired (and in Knex's case, mostly copied) from the excellent Laravel PHP framework's query builder and ORM. Bookshelf also adapts different conventions I found useful from Backbone.js' Models, Collections, and Events - I'm also aiming to eventually make the libraries usable outside of Node (webSQL or otherwise).

I've been looking to take the best from other languages' data interfaces and try to adapt them into a few great packages for javascript, as opposed to completely re-inventing the wheel.

Some of the differentiating features include eager-loading and nested eager-loading relations, the ability to constrain those relations[1], polymorphic relations, a distinct separation between the ORM and the query builder layer, and until recently transactions (which from what I've heard, sequelize has begun to add to the library).

Some things that Bookshelf doesn't have out of the box are explicit typecasting (hooks exist to handle this if you need, but most times the db takes care of this for you) or validations (IMO out of scope for Bookshelf/Knex, but something I'll have incorporated in my next database package), and static finder methods `User.find(1)`, `User.findOrCreate({...})` - easily added but these will also come in the next package in progress.

Bookshelf aims to be a simple Data-Mapper, rather than a full out Rails ActiveRecord style ORM... This is something that will be a different project entirely which I'm actively working on building out. Sitting atop of Bookshelf, it will include scopes, validators, callbacks, helper methods, etc.

[1]: https://github.com/tgriesser/bookshelf/issues/69#issuecommen...




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: