0.14.0 • Published 4 years ago

active-knex v0.14.0

Weekly downloads
10
License
MIT
Repository
github
Last release
4 years ago

ActiveKnex

Bringing the awesomeness of knex one step closer to ActiveRecord!

NOTE: While I think Bookshelf is a great project, it has the same annoyances that Backbone has where it puts a whole bunch of stuff that I don't want in and around my data. I want a raw Javascript Object!

Using ActiveKnex

var ActiveKnex = require('active-knex');
var knex = require('knex')(knexConfig);

// Create your very own Schema right on top of your existing knex object
var MySchema = ActiveKnex.Schema.create(knex, {
  tableName: 'table_name',
  // Everything else!
});

Relations

Want to load associations into your data object before you res.json? This is for you!

Define a Relation in your Schema

var Player = ActiveKnex.Schema.create(knex, {
  tableName: 'players',

  relations: {
    players: function() {
      var Player = require('./player');
      return ActiveKnex.Relation.HasMany({
        model: Player,
        foreignKey: 'team_id'
      });
    }
  }
});

###Load association data right into your Object

var team = {id: 1};
Team.load(team, 'players').then(function(team) {
  team.players; // Array of players
});

##Testing

To run the tests

npm install
mocha
    

More Documentation To Come!

0.13.3

4 years ago

0.14.0

4 years ago

0.13.2

4 years ago

0.13.1

5 years ago

0.13.0

5 years ago

0.12.1

5 years ago

0.12.0

5 years ago

0.11.0

5 years ago

0.10.3

6 years ago

0.10.2

6 years ago

0.10.1

6 years ago

0.10.0

6 years ago

0.9.0

6 years ago

0.8.0

6 years ago

0.2.8

7 years ago

0.7.3

7 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.15

7 years ago

0.6.14

7 years ago

0.6.13

7 years ago

0.6.12

7 years ago

0.6.11

7 years ago

0.6.10

7 years ago

0.6.9

7 years ago

0.6.8

7 years ago

0.6.7

8 years ago

0.6.6

8 years ago

0.6.5

8 years ago

0.6.4

8 years ago

0.6.3

8 years ago

0.6.2

8 years ago

0.6.1

8 years ago

0.6.0

8 years ago

0.5.3

8 years ago

0.5.2

8 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.6

8 years ago

0.4.5

8 years ago

0.4.4

8 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.9

9 years ago

0.1.8

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.1

9 years ago