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

Commit 278d0a2c by Mick Hansen

basic previous(key) functionality

1 parent 87d23614
Showing with 21 additions and 0 deletions
...@@ -179,6 +179,10 @@ module.exports = (function() { ...@@ -179,6 +179,10 @@ module.exports = (function() {
}.bind(this)) }.bind(this))
} }
DAO.prototype.previous = function(key) {
return this._previousDataValues[key]
}
DAO.prototype._setInclude = function(key, value, options) { DAO.prototype._setInclude = function(key, value, options) {
if (!Array.isArray(value)) value = [value] if (!Array.isArray(value)) value = [value]
if (value[0] instanceof DAO) { if (value[0] instanceof DAO) {
......
...@@ -184,5 +184,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () { ...@@ -184,5 +184,21 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
}) })
}) })
}) })
describe('previous', function () {
it('should return the previous value', function () {
var User = this.sequelize.define('User', {
name: {type: DataTypes.STRING}
})
var user = User.build({
name: 'Jan Meier'
})
user.set('name', 'Mick Hansen')
expect(user.previous('name')).to.equal('Jan Meier')
expect(user.get('name')).to.equal('Mick Hansen')
})
})
}) })
}) })
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!