the code like this:
(function () {
var tag = models.Tag.build({ create_time: new Date(), is_hot: '0', is_lock: '0', name: 'Nodejs' });
tag.save();
console.log(tag.dataValues);
tag.name = "npm";
tag.save();
console.log(tag.dataValues);
tag = models.Tag.build({ create_time: new Date(), is_hot: '0', is_lock: '0', name: 'webpack' });
tag.save();
console.log(tag.dataValues);
})();
the result is: the result
in my first eys,the result maybe:
Executing (default): INSERT INTO `t_tag` (`id`,`name`,`create_time`,`is_hot`,`is_lock`,`is_delete`) VALUES (NULL,'Nodejs','2016-12-23 03:09:23','0','0','0');
Executing (default): INSERT INTO `t_tag` (`id`,`name`,`create_time`,`is_hot`,`is_lock`,`is_delete`) VALUES (NULL,'npm','2016-12-23 03:09:23','0','0','0');
Executing (default): INSERT INTO `t_tag` (`id`,`name`,`create_time`,`is_hot`,`is_lock`,`is_delete`) VALUES (NULL,'webpack','2016-12-23 03:09:26','0','0','0');
what causes that ? why the "npm" record insert double time?
npmtag.name = "npm";it doesn't really change the value of columnnamein your build Tag and remember you trytag.save()again which it will just insert the previous value again that's why it insert twice(function () { var tag = models.Tag.build({ create_time: new Date(), is_hot: '0', is_lock: '0', name: 'Nodejs' }); console.log(tag.dataValues); tag.save(); tag.name = "npm"; })();, it also insert thenpm. TnT