Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bookshelf

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bookshelf

A lightweight ORM for PostgreSQL, MySQL, and SQLite3

  • 0.7.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30K
decreased by-52.07%
Maintainers
1
Weekly downloads
 
Created
Source

bookshelf.js Build Status

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 Docs, License, Tests, FAQ, and other information, see: http://bookshelfjs.org.

To suggest a feature, report a bug, or general discussion: http://github.com/tgriesser/bookshelf/issues/

Examples

We have several examples on the website. Here is the first one to get you started:

var knex = require('knex')({client: 'mysql', connection: process.env.MYSQL_DATABASE_CONNECTION });
var bookshelf = require('bookshelf')(knex);

var User = bookshelf.Model.extend({
  tableName: 'users'
  messages: function() {
    return this.hasMany(Posts);
  }
});

var Posts = bookshelf.Model.extend({
  tableName: 'messages',
  tags: function() {
    return this.belongsToMany(Tag);
  }
});

var Tag = bookshelf.Model.extend({
  tableName: 'tags'
})

User.where('id', 1).fetch({withRelated: ['posts.tags']}).then(function(user) {

  console.log(user.related('posts').toJSON());

}).catch(function(err) {

  console.error(err);

});

Keywords

FAQs

Package last updated on 28 Oct 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc