A lightweight ORM for PostgreSQL, MySQL, and SQLite3
Bookshelf is a Node.js ORM with support for PostgreSQL, MySQL / MariaDB, and SQLite3.
It is built atop the Knex query builder, and is strongly influenced by the Model and Collection foundations of Backbone.js.
It features transaction support, one-to-one, one-to-many, many-to-many, and polymorphic relations.
For documentation, FAQs, and other information, see: http://bookshelfjs.org.
To suggest a feature, report a bug, or for general discussion: http://github.com/tgriesser/bookshelf/issues/
We have several examples on the website. Here is the first one to get you started:
var knex = require'knex'client: 'mysql' connection: processenvMYSQL_DATABASE_CONNECTION ;var bookshelf = require'bookshelf'knex;var User = bookshelfModelextendtableName: 'users'return thishasManyPosts;;var Posts = bookshelfModelextendtableName: 'messages'return thisbelongsToManyTag;;var Tag = bookshelfModelextendtableName: 'tags'Userwhere'id' 1fetchwithRelated: 'posts.tags'thenconsole.loguserrelated'posts'toJSON;catchconsole.errorerr;;
To contribute to Bookshelf, read the contribution documentation for more information.