Metadata
Adding metadata to during a transaction allows you to capture context about the event. If you are using one of the frameworks in the table below, you can simply use the Changebase integration and avoid dealing with raw SQL.
Framework | Changebase Integration |
---|---|
Rails | Changebase Ruby |
If you are developing your own integration, simply include the metadata in the changebase_metadata
table during any transaction. All statements within the transaction will have the metadata associated with it.
For example, the following will create an event showing that the user with the id of 1 updated their email to [email protected]
.
BEGIN;
INSERT INTO changebase_metadata ( version, data )
VALUES ( 1, '{"user":{"id":1,"name":"Moses"}}' )
ON CONFLICT ( version ) DO UPDATE SET version = 1, data = '{"user":{"id":1,"name":"Moses"}}';
UPDATE accounts SET email = '[email protected]' WHERE id = 1;
COMMIT;
The metadata can then be used to lookup all changes made by a user, or any other attribute which you wish to track.
Updated over 2 years ago