不要怂,就是干,撸起袖子干!

Commit 5ac0d978 by Mick Hansen

Merge branch 'v3' of github.com:sequelize/sequelize into v3

2 parents 0f8bf474 9bf902da
Showing with 9 additions and 2 deletions
...@@ -2083,6 +2083,9 @@ Model.prototype.bulkCreate = function(records, options) { ...@@ -2083,6 +2083,9 @@ Model.prototype.bulkCreate = function(records, options) {
options.fields = options.fields || Object.keys(this.tableAttributes); options.fields = options.fields || Object.keys(this.tableAttributes);
// Expose model to global hooks
options.model = this;
var dialect = this.sequelize.options.dialect; var dialect = this.sequelize.options.dialect;
if (options.ignoreDuplicates && ['postgres', 'mssql'].indexOf(dialect) !== -1) { if (options.ignoreDuplicates && ['postgres', 'mssql'].indexOf(dialect) !== -1) {
return Promise.reject(new Error(dialect + ' does not support the \'ignoreDuplicates\' option.')); return Promise.reject(new Error(dialect + ' does not support the \'ignoreDuplicates\' option.'));
...@@ -2185,8 +2188,6 @@ Model.prototype.bulkCreate = function(records, options) { ...@@ -2185,8 +2188,6 @@ Model.prototype.bulkCreate = function(records, options) {
} }
} }
// Insert all records at once
options.model = self;
return self.QueryInterface.bulkInsert(self.getTableName(options), records, options, attributes).then(function (results) { return self.QueryInterface.bulkInsert(self.getTableName(options), records, options, attributes).then(function (results) {
if (Array.isArray(results)) { if (Array.isArray(results)) {
results.forEach(function (result, i) { results.forEach(function (result, i) {
...@@ -2342,6 +2343,9 @@ Model.prototype.restore = function(options) { ...@@ -2342,6 +2343,9 @@ Model.prototype.restore = function(options) {
options.type = QueryTypes.RAW; options.type = QueryTypes.RAW;
// Expose model to global hooks
options.model = this;
var self = this var self = this
, instances; , instances;
...@@ -2434,6 +2438,9 @@ Model.prototype.update = function(values, options) { ...@@ -2434,6 +2438,9 @@ Model.prototype.update = function(values, options) {
options.type = QueryTypes.BULKUPDATE; options.type = QueryTypes.BULKUPDATE;
// Expose model to global hooks
options.model = this;
this.$injectScope(options); this.$injectScope(options);
// Clone values so it doesn't get modified for caller scope // Clone values so it doesn't get modified for caller scope
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!