Comparing version 0.6.3 to 0.6.4
@@ -1,2 +0,2 @@ | ||
// Bookshelf.js 0.6.3 | ||
// Bookshelf.js 0.6.4 | ||
// --------------- | ||
@@ -57,2 +57,7 @@ | ||
// Shortcut for creating a new collection with the current collection. | ||
ModelCtor.collection = function(rows, options) { | ||
return new CollectionCtor((rows || []), _.extend({}, options, {model: this})); | ||
}; | ||
// The collection also references the correct `Model`, specified above, for creating | ||
@@ -86,3 +91,3 @@ // new `Model` instances in the collection. We also extend with the correct builder / | ||
// Keep in sync with `package.json`. | ||
VERSION: '0.6.3', | ||
VERSION: '0.6.4', | ||
@@ -89,0 +94,0 @@ // Helper method to wrap a series of Bookshelf actions in a `knex` transaction block; |
@@ -157,6 +157,10 @@ // Base Model | ||
options = options ? _.clone(options) : {}; | ||
var sync = this.sync(options); | ||
options.query = sync.query | ||
return Promise.bind(this).then(function() { | ||
return this.triggerThen('destroying', this, options); | ||
}).then(function() { | ||
return this.sync(options).del(); | ||
return sync.del(); | ||
}).then(function(resp) { | ||
@@ -163,0 +167,0 @@ this.clear(); |
@@ -132,3 +132,3 @@ // Model | ||
attrs = key || {}; | ||
options = val || {}; | ||
options = _.clone(val) || {}; | ||
} else { | ||
@@ -135,0 +135,0 @@ (attrs = {})[key] = val; |
{ | ||
"name": "bookshelf", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"description": "A lightweight ORM for PostgreSQL, MySQL, and SQLite3, influenced by Backbone.js", | ||
@@ -5,0 +5,0 @@ "main": "bookshelf.js", |
@@ -41,4 +41,5 @@ var Promise = require('../dialects/base/promise').Promise; | ||
base.Eager(); | ||
require('./unit/sql/sync')(); | ||
require('./unit/sql/model')(); | ||
@@ -45,0 +46,0 @@ }); |
@@ -276,3 +276,3 @@ var _ = require('lodash'); | ||
}); | ||
it('does not fail, when joining another table having some columns with the same names - #176', function () { | ||
@@ -479,2 +479,15 @@ var model = new Site({id: 1}); | ||
it('allows access to the query builder on the options object in the destroying event', function() { | ||
var m = new Site({id: 1}); | ||
m.sync = function () { | ||
var sync = stubSync; | ||
sync.query = m.query(); | ||
return sync; | ||
}; | ||
m.on('destroying', function(model, options) { | ||
expect(options.query.whereIn).to.be.a.function; | ||
}); | ||
return m.destroy(); | ||
}); | ||
}); | ||
@@ -687,4 +700,18 @@ | ||
describe('Model.collection', function() { | ||
it('creates a new collection for the current model', function() { | ||
expect(Bookshelf.Model.collection()).to.be.an.instanceOf(Bookshelf.Collection); | ||
var NewModel = Bookshelf.Model.extend({test: 1}); | ||
var newModelCollection = NewModel.collection([{id: 1}]); | ||
expect(newModelCollection).to.be.an.instanceOf(Bookshelf.Collection); | ||
expect(newModelCollection.at(0)).to.be.an.instanceOf(NewModel); | ||
}); | ||
}); | ||
}); | ||
}; |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
282263
54
7756
12