-
-
Notifications
You must be signed in to change notification settings - Fork 611
Description
Is your feature request related to a problem? Please describe.
I can't find a way to read the change set of an entity. Basically I'd like to implement some kind of papertrail feature where I could log, in a dedicated table (let's call it versions here), the changes that occur to specific entities. That would include the before and after save states of the entity.
Describe the solution you'd like
Ideally I'd like:
- a way to read the current change set of an entity:
EntityManager.getChangeSet(entity) - a way to write into the
versionstable upon events like create or update (as far as I understand current limitations on the lifecycle hooks, I can't do it from a @AfterUpdate as it is today). I imagine an event that I can listen to that carries the change set would work.
Describe alternatives you've considered
I've looked at the existing lifecycle hooks but limitations are pretty clear and well explained, seems to be a dead end.
I've dig into the UnitOfWork and ChangeSet code but couldn't find anything relevant.
I would like not to have to use/write a MySQL binlog parser.
Additional context
My end goal is to have something that looks like https://www.npmjs.com/package/sequelize-paper-trail adapted for mikro-orm, but I don't want to ask for the whole thing, I just need the means to do it so I can do it myself.
If you think I already have everything I need today and I just couldn't find it please point me to the relevant functions and classes.