Sync function... how do I update doc1 when doc2 is inserted?

Thanks @adamf!

So, my options for AuthorX.Books are:

  1. Use a count view every time I want to know how many books are associated with AuthorX
  • this requires couchbase to actually do the math on every read request which is an ongoing hit on performance (not a big deal for count, but if it’s a function with more complicated math, this could be significant)
  • but we know the count is accurate (there’s no chance of deleting BookY and forgetting to update AuthorX.Books)
  1. Use “Changes Worker Pattern

  2. Use “Webhooks

  • “Prior to the 1.1 release, the only way to add custom logic in the form of plugins to Sync Gateway was to listen on the changes feed. While this approach still works, it isn’t the easiest to setup. With webhooks, you can simply provide a filter function and the URL to post the event to. Then, you handle the event with the back-end language of your choice (NodeJS, Java, Go, Ruby…).”

I think Webhooks is the way to go. By filtering “changes” you only spend CPU operation on the ones you care about.

Kind regards,
David