Featuring both promise based and traditional callback interfaces, providing transaction support, eager/nested-eager relation loading, polymorphic associations, and support for one-to-one, one-to-many, and many-to-many relations.
It is designed to work well with Postgre SQL, My SQL, and SQLite3. The project is hosted on Git Hub, and has a comprehensive test suite. You may want to read the discussion about the future of on Git Hub.
It doesn't force you to use any specific validation scheme, provides flexible and efficient relation/nested-relation loading, and first class transaction support.
It's a lean Object Relational Mapper, allowing you to drop down to the raw knex interface whenever you need a custom query that doesn't quite fit with the stock conventions.
Librarians are not Goodreads employees or representatives of the company. If you believe a member's librarian edits contradict our librarian manual, please contact a staff member.
If you would like to become a librarian and have at least 50 books on your profile, you can apply here. Premium Giveaway (Print or Kindle) 9 per giveaway.
A common pattern to follow is to initialize the client in a module so you can easily reference it later: // In a file named something like var knex = require('knex')(db Config); module.exports = require('bookshelf')(knex); // elsewhere, to use the bookshelf client: var bookshelf = require('./bookshelf'); var Post = bookshelf. Model.extend() User.where('id', 1).fetch().then(function(user) ).catch(function(err) ); Have questions about the library?
We found the following projects using Bookshelf, but there can be more: You sometimes need to manipulate data from the database into the correct types.
Bookshelf aims to provide a simple library for common tasks when querying databases in Java Script, and forming relations between these objects, taking a lot of ideas from the the Data Mapper Pattern.
With a concise, literate codebase, Bookshelf is simple to read, understand, and extend.