You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to make a table store its own history by simply referencing the value of the primary key upon update.
I figure this can be done with hooks, but I need more information... but very unsure.
I won't need this for bulkInsert, as I will be denying that action.
SomeModel.init({// some fields...id: DataTypes.INTEGER//...createdAt: DataTypes.DATE,deletedAt: DataTypes.DATE},{// some props...hooks: {beforeUpdate: (instance,options)=>{constinstanceValues=instance.get();// Should be the updated values, right?deleteinstanceValues.id;instance.destroy({transaction: options.transaction})// Does this destroy the instance, in-place, with no updates?SomeModel.create({
...instanceValues,previousVersionId: instanceValues.id,createdAt: newDate(),},{transaction: options.transaction});}}})
Also if anyone knows the types used (v6) so I can use a generic function, that would be appreciated.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'd like to make a table store its own history by simply referencing the value of the primary key upon update.
I figure this can be done with hooks, but I need more information... but very unsure.
I won't need this for bulkInsert, as I will be denying that action.
Also if anyone knows the types used (v6) so I can use a generic function, that would be appreciated.
Beta Was this translation helpful? Give feedback.
All reactions