Socket
Socket
Sign inDemoInstall

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.1.8 to 0.1.9

plugins/exec.js

23

bookshelf.js

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

// Bookshelf.js 0.1.8
// Bookshelf.js 0.1.9

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

// Keep in sync with `package.json`.
Bookshelf.VERSION = '0.1.8';
Bookshelf.VERSION = '0.1.9';

@@ -344,11 +344,10 @@ // We're using `Backbone.Events` rather than `EventEmitter`,

.then(function() { return resp; });
} else {
if (options.require) return when.reject(new Error('EmptyResponse'));
model.clear({silent: true})._reset();
return {};
}
if (options.require) return when.reject(new Error('EmptyResponse'));
})
.then(function(resp) {
model.trigger('fetched', model, resp, options);
return model;
if (resp && resp.length > 0) {
model.trigger('fetched', model, resp, options);
return model;
}
});

@@ -456,5 +455,6 @@ },

var d = new Date();
var keys = (_.isArray(this.hasTimestamps) ? this.hasTimestamps : ['created_at', 'updated_at']);
var vals = {};
vals.updated_at = d;
if (this.isNew(options)) vals.created_at = d;
vals[keys[1]] = d;
if (this.isNew(options)) vals[keys[0]] = d;
return vals;

@@ -865,3 +865,4 @@ },

first: function() {
this.query.where(extendNull(this.syncing.attributes)).limit(1);
var syncing = this.syncing;
this.query.where(syncing.format(extendNull(syncing.attributes))).limit(1);
return this.select();

@@ -868,0 +869,0 @@ },

{
"name": "bookshelf",
"version": "0.1.8",
"description": "A lightweight ORM for Postgres, MySQL, and SQLite3 with some Backbone",
"version": "0.1.9",
"description": "A lightweight Active Record ORM for PostgreSQL, MySQL, and SQLite3, influenced by Backbone.js",
"main": "bookshelf.js",

@@ -6,0 +6,0 @@ "scripts": {

@@ -30,2 +30,33 @@ var _ = require('underscore');

});
describe('Plugins', function() {
describe('exec', function() {
it('adds `then` and `exec` to all sync methods', function() {
require('../plugins/exec');
var model = new Bookshelf.Model();
var collection = new Bookshelf.Collection();
_.each(['load', 'fetch', 'save', 'destroy'], function(method) {
var fn = model[method]();
if (!_.isFunction(fn.then) || !_.isFunction(fn.exec)) {
throw new Error('then and exec are not both defined');
}
});
_.each(['load', 'fetch'], function(method) {
var fn = collection[method]();
if (!_.isFunction(fn.then) || !_.isFunction(fn.exec)) {
throw new Error('then and exec are not both defined');
}
});
});
});
});

@@ -385,2 +385,15 @@ /*global describe, it */

});
it('allows custom keys for the created at & update at values', function(ok) {
var m = new Bookshelf.Model(null, {hasTimestamps: ['createdAt', 'updatedAt']});
m.sync = function() {
equal(this.get('item'), 'test');
equal(_.isDate(this.get('createdAt')), true);
equal(_.isDate(this.get('updatedAt')), true);
ok();
return stubSync;
};
m.save({item: 'test'});
});
});

@@ -387,0 +400,0 @@

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