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.5.0 to 0.5.1

4

bookshelf.js

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

// Bookshelf.js 0.5.0
// Bookshelf.js 0.5.1

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

// Keep in sync with `package.json`.
VERSION: '0.5.0',
VERSION: '0.5.1',

@@ -88,0 +88,0 @@ // Helper method to wrap a series of Bookshelf actions in a `knex` transaction block;

@@ -246,4 +246,4 @@ // Relation

var grouped = _.groupBy(related, function(model) {
return this.isSingle() ? model.id : (model.pivot ?
model.pivot.get(this.key('foreignKey')) : model.get(this.key('foreignKey')));
return model.pivot ? model.pivot.get(this.key('foreignKey')) :
this.isInverse() ? model.id : model.get(this.key('foreignKey'));
}, this);

@@ -250,0 +250,0 @@

{
"name": "bookshelf",
"version": "0.5.0",
"version": "0.5.1",
"description": "A lightweight ORM for PostgreSQL, MySQL, and SQLite3, influenced by Backbone.js",

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

@@ -186,4 +186,16 @@ var when = require('when');

knex('users_roles').insert({uid: 1, rid: 4})
knex('users_roles').insert({uid: 1, rid: 4}),
knex('Customer').insert([
{id: 1, name: 'Customer1'},
{id: 2, name: 'Customer2'},
{id: 3, name: 'Customer3'},
{id: 4, name: 'Customer4'}]),
knex('Settings').insert([
{id: 1, Customer_id: 1, data: 'Europe/Paris'},
{id: 2, Customer_id: 4, data: 'UTC'}
])
]).then(null, function(e) {

@@ -190,0 +202,0 @@ console.log(e.stack);

@@ -8,3 +8,3 @@ var _ = require('underscore');

'blogs', 'posts', 'tags', 'posts_tags', 'comments',
'users', 'roles', 'photos', 'users_roles', 'info'
'users', 'roles', 'photos', 'users_roles', 'info', 'Customer', 'Settings'
];

@@ -120,2 +120,13 @@

table.string('imageable_type');
}),
schema.createTable('Customer', function(table) {
table.increments('id');
table.string('name');
}),
schema.createTable('Settings', function(table) {
table.increments('id');
table.integer('Customer_id');
table.string('data', 64);
})

@@ -122,0 +133,0 @@

@@ -184,2 +184,12 @@

// Define the model
var Settings = Bookshelf.Model.extend({ tableName: 'Settings' });
var Customer = Bookshelf.Model.extend({
tableName: 'Customer',
settings: function () {
return this.hasOne(Settings);
}
});
return {

@@ -198,3 +208,5 @@ Models: {

Photo: Photo,
Info: Info
Info: Info,
Customer: Customer,
Settings: Settings
},

@@ -201,0 +213,0 @@ Collections: {

@@ -14,13 +14,14 @@ var when = require('when');

// Models
var Site = Models.Site;
var SiteMeta = Models.SiteMeta;
var Admin = Models.Admin;
var Author = Models.Author;
var Blog = Models.Blog;
var Post = Models.Post;
var Comment = Models.Comment;
var Tag = Models.Tag;
var User = Models.User;
var Role = Models.Role;
var Photo = Models.Photo;
var Site = Models.Site;
var SiteMeta = Models.SiteMeta;
var Admin = Models.Admin;
var Author = Models.Author;
var Blog = Models.Blog;
var Post = Models.Post;
var Comment = Models.Comment;
var Tag = Models.Tag;
var User = Models.User;
var Role = Models.Role;
var Photo = Models.Photo;
var Customer = Models.Customer;

@@ -349,4 +350,47 @@ // Collections

describe('Issue #63 - hasOne relations', function() {
it('should return Customer (id=1) with settings', function (done) {
var expected = {
id : 1,
name : 'Customer1',
settings: {
id : 1,
Customer_id : 1,
data : 'Europe/Paris'
}
};
return new Customer({ id: 1 })
.fetch({ withRelated: 'settings' })
.then(function (model) {
var cust = model.toJSON();
expect(cust).to.eql(expected);
});
});
it('should return Customer (id=4) with settings', function (done) {
var expected = {
id : 4,
name : 'Customer4',
settings: {
id : 2,
Customer_id : 4,
data : 'UTC'
}
};
return new Customer({ id: 4 })
.fetch({ withRelated: 'settings' })
.then(function (model) {
var cust = model.toJSON();
expect(cust).to.eql(expected);
});
});
});
});
};
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