Webhook Sync Gateway

Hi,

running on:

  • SGW 2.0 beta
  • CBL 2.0 beta
  • CBS 5.1

The SGW examples mention this for filtering and webhooks:

"event_handlers": {
      "document_changed": [
        {"handler": "webhook",
         "url": "http://someurl.com"},
        {"handler": "webhook",
         "url": "http://someurl.com/some_type",
         "timeout": 30,
         "filter": `function(doc) {
              if (doc.type == "some_type") {
                return true;
              }
              return false;
            }`
        }
      ]
    }

Is it possible to do this for the filter?:

"filter": `function(doc, oldDoc) {
              if (doc.stock.quantity != doc.stock.quantity) {
                return true;
              }
              return false;
            }`

Or is there some alternative to spot a change on a detail level or only global?

1 Like

I think you can not get oldDoc parameter in filter function.

https://developer.couchbase.com/documentation/mobile/current/guides/sync-gateway/server-integration/index.html

FYI

1 Like