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 - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

33

bookshelf.js

@@ -1,2 +0,2 @@

// Bookshelf.js 0.3.0
// Bookshelf.js 0.3.1

@@ -32,3 +32,3 @@ // (c) 2013 Tim Griesser

// Keep in sync with `package.json`.
Bookshelf.VERSION = '0.3.0';
Bookshelf.VERSION = '0.3.1';

@@ -98,4 +98,4 @@ // We're using `Backbone.Events` rather than `EventEmitter`,

// matches the primary `idAttribute` of another table.
belongsTo: function(Target, otherKey) {
return new Relation('belongsTo', Target, {otherKey: otherKey}).init(this);
belongsTo: function(Target, foreignKey) {
return new Relation('belongsTo', Target, {foreignKey: foreignKey}).init(this);
},

@@ -1005,3 +1005,3 @@

}
this.parentFk = parent.get(this.key('otherKey'));
this.parentFk = parent.get(this.key('foreignKey'));
} else {

@@ -1055,3 +1055,2 @@ this.parentFk = parent.id;

if (keyName === 'otherKey') {
if (this.type === 'morphTo') return this[keyName] = this.morphName + '_id';
return this[keyName] = singularMemo(this.targetTableName) + '_' + this.targetIdAttribute;

@@ -1063,2 +1062,4 @@ }

if (keyName === 'foreignKey') {
if (this.type === 'morphTo') return this[keyName] = this.morphName + '_id';
if (this.type === 'belongsTo') return this[keyName] = singularMemo(this.targetTableName) + '_' + this.targetIdAttribute;
if (this.isMorph()) return this[keyName] = this.morphName + '_id';

@@ -1102,9 +1103,5 @@ return this[keyName] = singularMemo(this.parentTableName) + '_' + this.parentIdAttribute;

var joinTable = this.joinTable();
if (this.isThrough()) {
columns.push(this.throughIdAttribute, this.type === 'belongsTo' ? this.key('otherKey') : this.key('foreignKey'));
if (this.type === 'belongsToMany') columns.push(this.key('otherKey'));
} else {
columns.push(this.key('foreignKey'));
if (this.type === 'belongsToMany') columns.push(this.key('otherKey'));
}
if (this.isThrough()) columns.push(this.throughIdAttribute);
columns.push(this.key('foreignKey'));
if (this.type === 'belongsToMany') columns.push(this.key('otherKey'));
push.apply(columns, this.pivotColumns);

@@ -1121,5 +1118,8 @@ push.apply(knex.columns, _.map(columns, function(col) {

if (this.type === 'belongsTo' || this.type === 'belongsToMany') {
var targetKey = (this.type === 'belongsTo' ? this.key('foreignKey') : this.key('otherKey'));
knex.join(
joinTable,
joinTable + '.' + this.key('otherKey'), '=',
joinTable + '.' + targetKey, '=',
this.targetTableName + '.' + this.targetIdAttribute

@@ -1136,2 +1136,3 @@ );

}
} else {

@@ -1167,3 +1168,3 @@ knex.join(

eagerKeys: function(resp) {
return _.uniq(_.pluck(resp, this.isInverse() ? this.key('otherKey') : this.parentIdAttribute));
return _.uniq(_.pluck(resp, this.isInverse() ? this.key('foreignKey') : this.parentIdAttribute));
},

@@ -1237,3 +1238,3 @@

var model = models[i];
var groupedKey = this.isInverse() ? model.get(this.key('otherKey')) : model.id;
var groupedKey = this.isInverse() ? model.get(this.key('foreignKey')) : model.id;
model.relations[relationName] = this.relatedInstance(grouped[groupedKey]);

@@ -1240,0 +1241,0 @@ }

{
"name": "bookshelf",
"version": "0.3.0",
"version": "0.3.1",
"description": "A lightweight Active Record ORM for PostgreSQL, MySQL, and SQLite3, influenced by Backbone.js",

@@ -5,0 +5,0 @@ "main": "bookshelf.js",

@@ -155,3 +155,3 @@ var When = require('when');

equal(relatedData.targetIdAttribute, 'id');
equal(relatedData.foreignKey, undefined);
equal(relatedData.foreignKey, 'supplier_id');

@@ -158,0 +158,0 @@ // Init

@@ -185,5 +185,5 @@ var When = require('when');

Knex('roles').insert({rid: 1, name: 'admin'}),
Knex('roles').insert({rid: 4, name: 'admin'}),
Knex('users_roles').insert({uid: 1, rid: 1})
Knex('users_roles').insert({uid: 1, rid: 4})

@@ -190,0 +190,0 @@ ]).then(null, function(e) {

@@ -161,3 +161,3 @@

roles: function() {
return this.belongsToMany(Role, 'users_roles', 'rid', 'uid');
return this.belongsToMany(Role, 'users_roles', 'uid', 'rid');
}

@@ -170,3 +170,3 @@ });

users: function(){
return this.belongsToMany(User, 'users_roles', 'uid', 'rid');
return this.belongsToMany(User, 'users_roles', 'rid', 'uid');
}

@@ -173,0 +173,0 @@ });

Sorry, the diff of this file is too big to display

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