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

Commit 4cf1cc77 by Mick Hansen

fix hooks

1 parent eb77dfb9
......@@ -223,7 +223,6 @@ module.exports = (function() {
}
if (type === 'set') {
funcs[attribute] = function(value) {
console.log(this)
return this.set(attribute, value)
}
}
......
......@@ -246,20 +246,20 @@ module.exports = (function() {
options.fields.push(createdAtAttr)
}
}
var tmpVals = self.dataValues
options.fields.forEach(function(field) {
if (tmpVals[field] !== undefined) {
values[field] = tmpVals[field]
}
})
}
return new Utils.CustomEventEmitter(function(emitter) {
self.hookValidate().error(function(err) {
emitter.emit('error', err)
}).success(function() {
var tmpVals = self.dataValues
options.fields.forEach(function(field) {
if (tmpVals[field] !== undefined) {
values[field] = tmpVals[field]
}
})
for (var attrName in self.daoFactory.rawAttributes) {
if (self.daoFactory.rawAttributes.hasOwnProperty(attrName)) {
var definition = self.daoFactory.rawAttributes[attrName]
......
......@@ -713,8 +713,6 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
expect(users[0].secretValue).to.be.null
done()
})
}).on('sql', function (sql) {
console.log(sql)
})
})
......
......@@ -23,6 +23,7 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
}, {
hooks: {
beforeValidate: function(user, fn) {
console.log("beforeValidate")
user.mood = 'happy'
fn(null, user)
},
......@@ -111,7 +112,7 @@ describe(Support.getTestDialectTeaser("Hooks"), function () {
self.User.all().success(function(users) {
expect(users[0].mood).to.equal('happy')
expect(users[0].mood).to.equal('happy')
expect(users[1].mood).to.equal('happy')
done()
})
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!