-
-
Notifications
You must be signed in to change notification settings - Fork 45
Docs for common use cases #14
Description
Hey, I find this extension really useful 🙏
I am not sure about how some of the use cases should be approached with such a table.
Getting the history of a particular row
If I I want to get the history of a particular row from the primary table, should I query on the primary key inside of JSONB record?
Getting the most recent version of a particular row
I think that if I can get the history then the row with the latest ts is the most recent. So no question here 😄
Getting the previous record from the most recent record
It got a little bit confusing here. I thought that record_id would be unique for every record (we could hash record contents and ts to achieve uniqueness). With that in mind we could find the previous record by looking at old_record_id of the record (a linked list essentially).
But that is not how it works 🤔 The old_record_id and record_id are always the same, because they're based on the primary keys which don't change for the tracked record. I am not sure I understand the purpose of having to identical ids for each record... And I have hard time understanding the purpose of record_id itself – I don't know record_id beforehand to select based on its value. I have to query JSONB for the primary key that I know, and while at that I can just select all rows that match (and they will all have the same record_id).
I think I'm missing something that prevents me from using this extension correctly, so I would really appreciate your answer!