Comparing version 0.2.7 to 0.2.8
@@ -1,2 +0,2 @@ | ||
// Bookshelf.js 0.2.7 | ||
// Bookshelf.js 0.2.8 | ||
@@ -30,3 +30,3 @@ // (c) 2013 Tim Griesser | ||
// Keep in sync with `package.json`. | ||
Bookshelf.VERSION = '0.2.7'; | ||
Bookshelf.VERSION = '0.2.8'; | ||
@@ -415,3 +415,6 @@ // We're using `Backbone.Events` rather than `EventEmitter`, | ||
]) | ||
.then(function() { return sync[method](attrs, options); }) | ||
.then(function() { | ||
var attrs = model.attributes; | ||
return sync[method](attrs, options); | ||
}) | ||
.then(function(resp) { | ||
@@ -963,7 +966,7 @@ | ||
// Issues an `insert` command on the query - only used by models. | ||
insert: function() { | ||
insert: function(attrs) { | ||
var syncing = this.syncing.resetQuery(); | ||
return this.query | ||
.idAttribute(syncing.idAttribute) | ||
.insert(syncing.format(extendNull(syncing.attributes))); | ||
.insert(syncing.format(extendNull(attrs))); | ||
}, | ||
@@ -973,8 +976,10 @@ | ||
update: function(attrs, options) { | ||
var syncing = this.syncing.resetQuery(); | ||
var query = this.query; | ||
var query = this.query, syncing = this.syncing.resetQuery(); | ||
if (syncing.id != null) { | ||
query.where(syncing.idAttribute, syncing.id); | ||
} | ||
return query.update(syncing.format(extendNull(syncing.attributes))); | ||
if (query.wheres.length === 0) { | ||
return when.reject(new Error('A model cannot be updated without a "where" clause or an idAttribute.')); | ||
} | ||
return query.update(syncing.format(extendNull(attrs))); | ||
}, | ||
@@ -984,11 +989,10 @@ | ||
del: function() { | ||
var wheres, syncing = this.syncing.resetQuery(); | ||
var query = this.query, syncing = this.syncing.resetQuery(); | ||
if (syncing.id != null) { | ||
wheres = {}; | ||
wheres[syncing.idAttribute] = syncing.id; | ||
query.where(syncing.idAttribute, syncing.id); | ||
} | ||
if (!wheres && this.query.wheres.length === 0) { | ||
if (query.wheres.length === 0) { | ||
return when.reject(new Error('A model cannot be destroyed without a "where" clause or an idAttribute.')); | ||
} | ||
return this.query.where(wheres).del(); | ||
return this.query.del(); | ||
} | ||
@@ -995,0 +999,0 @@ }); |
{ | ||
"name": "bookshelf", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"description": "A lightweight Active Record ORM for PostgreSQL, MySQL, and SQLite3, influenced by Backbone.js", | ||
@@ -5,0 +5,0 @@ "main": "bookshelf.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
172972
4648