GithubHelp home page GithubHelp logo

rakesh-mohanta / bookshelf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bookshelf/bookshelf

0.0 3.0 0.0 8.19 MB

A Node.js ORM for PostgreSQL, MySQL and SQLite3 in the style of Backbone.js

Home Page: bookshelfjs.org

License: MIT License

JavaScript 99.65% CSS 0.35%

bookshelf's Introduction

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);

});

bookshelf's People

Contributors

adriano-di-giovanni avatar alliejanoch avatar bendrucker avatar benesch avatar bniwredyc avatar danb235 avatar delasteve avatar epowers avatar fay-jai avatar gaarf avatar gildo avatar heinrichfilter avatar ipoddubny avatar jgable avatar joepie91 avatar johanneslumpe avatar jordaaash avatar madarche avatar matyo91 avatar maxluzuriaga avatar nathggns avatar notbobthebuilder avatar p-baleine avatar patrickjs avatar pschuegr avatar strathausen avatar tgriesser avatar therobinkim avatar wbyoung avatar werkt avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.