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

Commit 2b782f5e by Mick Hansen

feat(instance.get): provide clone: true option to .get()

1 parent 5eff94e1
Showing with 19 additions and 1 deletions
......@@ -193,7 +193,7 @@ module.exports = (function() {
return this.dataValues[key];
}
if (this._hasCustomGetters || (options && options.plain && this.options.include)) {
if (this._hasCustomGetters || (options && options.plain && this.options.include) || (options && options.clone)) {
var values = {}
, _key;
......
......@@ -355,6 +355,24 @@ describe(Support.getTestDialectTeaser('DAO'), function() {
expect(product.get({plain: true}).user.$Model).not.to.be.ok;
});
});
describe('clone', function() {
it('should copy the values', function () {
var Product = this.sequelize.define('product', {
title: Sequelize.STRING
});
var product = Product.build({
id: 1,
title: 'Chair',
}, {raw: true});
var values = product.get({clone: true});
delete values.title;
expect(product.get({clone: true}).title).to.be.ok;
});
});
});
describe('changed', function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!