Live data from Hacker News

Bookshelf.js: An ORM for Node.js with transactions, eager loading, promises

bookshelfjs.org

1–10 of 16 posts

Re: Bookshelf.js: An ORM for Node.js with transactions, eager loading, promises

#7

This is a port of Eloquent from Laravel [0], which is brilliant. I haven't used this, but if it's a faithful port it'll be awesome. [0] https://twitter.com/laravelphp/status/333971780886728705

The underlying query builder - http://knexjs.org - is much more of a 1-to-1 port. Bookshelf shares a number of similar features with eloquent, such as the process of defining relations, and handling eager/nested eager loading, but it also draws a lot of inspiration (and code) from the Model & Collection patterns of Backbone.js.

I owe a lot of thanks to Taylor for writing Eloquent, he has been really helpful with any questions I've had in putting this together.

Re: Bookshelf.js: An ORM for Node.js with transactions, eager loading, promises

#8
This looks really great! One thing really bothers me however: a dependency on all of Backbone. Pulling in a bunch a view-related code for an ORM has a certain code smell.

Is there any effort to modularize Backbone itself, so that Bookshelf can only depend on the model and collection pieces?

Re: Bookshelf.js: An ORM for Node.js with transactions, eager loading, promises

#9

This looks really great! One thing really bothers me however: a dependency on all of Backbone. Pulling in a bunch a view-related code for an ORM has a certain code smell. Is there any effort to modularize Backbone itself, so that Bookshelf can only depend on the model and collection pieces?

Thanks for checking it out! While the view/history/router related code should be okay just sitting there unused, I agree that does seem like a bit of a code smell. I know Jeremy has been against modularizing Backbone in the past, and there is something to be said about keeping everything packaged nicely together in a single file - though maybe something like this would change his mind.

It's definitely something I'll begin to look into a bit, possibly splitting up the Backbone components into a separate library specifically for Bookshelf, similar to lodash's custom build process. If you have any ideas for a good way to go about this, feel free to open a ticket.

Re: Bookshelf.js: An ORM for Node.js with transactions, eager loading, promises

#10

This is a port of Eloquent from Laravel [0], which is brilliant. I haven't used this, but if it's a faithful port it'll be awesome. [0] https://twitter.com/laravelphp/status/333971780886728705

The underlying query builder - http://knexjs.org - is much more of a 1-to-1 port. Bookshelf shares a number of similar features with eloquent, such as the process of defining relations, and handling eager/nested eager loading, but it also draws a lot of inspiration (and code) from the Model & Collection patterns of Backbone.js. I owe a lot of thanks to Taylor for writing Eloquent, he has been really helpful with any…

I love Eloquent and I love Backbone. It's awesome to see that you've harmonized the two for Node. I've only used SQL with Node once, and wrote raw queries for the most part. I'm looking forward to refactoring everything to use this.

Nice work!

Post reply on HN