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

Commit 3c4cbad3 by Vangelis Tsoumenis

added test for selective saving.

1 parent 0e11c0ce
Showing with 19 additions and 2 deletions
......@@ -40,5 +40,23 @@ module.exports = {
}, 100)
}, 100)
})
} ,
'save should only update fields in passed-array': function(exit) {
var User = sequelize.define('User' + parseInt(Math.random() * 99999999), { name: Sequelize.STRING, bio: Sequelize.TEXT })
User.sync({force: true}).on('success', function() {
var u = User.build({name: 'foo', bio: 'bar'});
u.save().on('success', function() {
var id = u.id;
u.name = 'fizz';
u.bio = 'buzz';
u.save(['name']).on('success', function(){
User.find(id).on('success', function(u2){ // re-select user
assert.eql('fizz', u2.name);
assert.eql('bar', u2.bio); // bio should be unchanged
exit(function(){});
});
});
})
});
}
}
\ 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!