JarvusInnovations / lapidus

Stream your PostgreSQL, MySQL or MongoDB databases anywhere, fast.
MIT License
171 stars 22 forks source link

Before and after update record #11

Closed masrodjie closed 7 years ago

masrodjie commented 7 years ago

Is it possible to send event data before and after update record in the table? So we can only get the value column changes. Thanks

jmealo commented 7 years ago

@masrodjie: Sorry, I missed this. I switched jobs and no longer have ownership of this repo. You'll typically want to do that in a trigger within the database. Since Lapidus uses replication streams, it only sees the UPDATE after it has already been staged/committed (depending on the database and replication settings). There's no way to calculate a delta (unless you have the original row somewhere else).

If you want to keep the "old" values, check out temporal tables (full audit log): https://en.wikipedia.org/wiki/Temporal_database

Example implementations of temporal databases should contain some helpful examples for the type of trigger you'd need to write.

If you want to store the revision history in something small that scales independently of PostgreSQL you can check out Tarantool.

Thank you for checking out Lapidus, I hope you found a solution that meets your needs. If you're still looking for a solution I can try to help point you in the right direction with PostgreSQL.