Bookshelf is a Node.js ORM built on Knex query builder, supporting PostgreSQL, MySQL, and SQLite3. Version 1.2.0 (latest stable) is actively maintained with a test suite on Travis CI. It provides promise-based and callback interfaces, eager/nested-eager loading, transactions, and polymorphic associations. Unlike full-featured ORMs like Sequelize, Bookshelf is lean, data-mapper oriented, and encourages dropping to raw Knex for custom queries. Release cadence is irregular, with security fixes prioritized. Requires peer dependency knex >=0.15.0 <0.22.0 and a database driver (pg, mysql, sqlite3).
npm install bookshelfNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up Bookshelf with Knex, defines three models with relations, and fetches a user with nested eager loading.
Pin knex to 0.21.x or 0.19.x (check compat). Use lockfile.
Use bookshelf.model('Name', { ... }) instead.Run knex migrate:latest or create tables manually.
Use dynamic import or CJS require. ESM: import bookshelf from 'bookshelf'; const b = bookshelf(knex);
Use `const bookshelf = require('bookshelf')(knex);`Create the database using `CREATE DATABASE myapp_test;` or change connection settings.
Ensure `const bookshelf = require('bookshelf')(knex);` is executed before using bookshelf methods.