Getting the old doc from a Sync Gateway Webhook

CBS: 6.0 CE
SG: 2.1

Hi everyone

I am looking for a reliable way to trigger a script on my web app on creation and/or update of specific document properties. It should be relatively easy to implement if I could get the old doc along with the new from the SG Webhook document_changed handler, but it does not seem like this is possible. The tricky part is that I need to know what has changed so that I can respond appropriately. One solution might be to store the previous values of those I need to track on update, and retrieve it from the doc itself, but that would require quite a bit of rework on the current implementation and not offer a neat, generic approach.

Has anyone worked with a similar requirement before? Do you maybe have any advice on how to achieve the need reliably?

Any advice or ideas would be much appreciated.

@adamf Any chance you have any ideas for me?

I don’t believe it’s possible to get the old document body from the webhook. You’ll have to keep track of it yourself.