Reputation: 499
I used Model.upsert function in sequelize. This method returns [record, created] that the record field is the upserted instance. I called this function with the exact duplicate data from database and in the return result, all the fields in _previousDataValues are undefined and the _changed Set contains all the fields.
I need a way to understand which fields have been changed (in this case zero fields because data is duplicate) without using a find query. One way is to compare _previousDataValues with dataValues but all the fields _previousDataValues are undefined. Another way would be through _changed but the _changed contains all fields although no field has been changed.
I'd appreciate if someone helps me to get the changed fields.
Upvotes: 0
Views: 679