This is an interesting use of the document history. I would think your safest way to do this would be with custom UDFs that perform the desired function (
Delete()), then make the update to the history document once those complete. Then you’d call
CustomCreate() (for example) when normally you’d call
If you’re using the document history in this way you might want a custom
Remove() function, as well; or only allow very limited access via ABAC to that function so that no one accidentally, or maliciously, removes the document history you’re depending on.
One thing to bare in mind with this approach: as your history increases, the read operations on that collection and any associated indexes will increase, as well. This is because an index needs to read through the history of any documents associated with it to make sure it’s getting the right one(s). So you might instead opt to still use custom functions to record the operation,
editedBy, but do so in a dedicated collection instead of the history. That would avoid those issues with large history collections. It would also potentially allow for much shorter history retention, since the audit data would now be stored separate from it and would not be in danger of being garbage collected.