A newer version of this documentation is available.

View Latest

Examples: Using the Eventing Service

      +

      This page contains examples of how to use the Eventing Service, using the Couchbase Web Console.

      Step by Step Examples

      Detailed Examples: These tutorial-like guides are ideal for a novice to learn the basics of the Eventing Service, via complete detailed step by step start-to-finish instructions.

      Data Enrichment

      Cascade Delete

      Document Expiry

      Delete v Expiry

      Document Archival

      Cancel or Overwrite Timer

      Recurring Timer

      External REST via cURL GET

      Risk Assessment

      Scriptlets or Terse Examples

      Basic KV Eventing Functions: The following Scriptlets are essentially stand alone Eventing Functions examples, and introduce more use cases. Here we assume the reader has a good understanding of the Eventing System and requires little guidance.

      basicBucketOps

      basicCurlGet

      basicCurlPost

      simpleTimer

      cascadeKvDeleteWithDoc

      redactSharedData

      simpleFlatten

      fixEmailDomains

      keepLastN

      docControlledSelfExpiry

      shippingNotifier

      ConvertBucketToCollections

      Basic N1QL Eventing Functions: The following Scriptlets demonstrate using N1QL or the Query Service from within an Eventing Function.

      basicN1qlSelectStmt

      basicN1qlPreparedSelectStmt

      Generic Manipulation Eventing Functions The following Scriptlets are more advanced use cases which focus on mutating documents without knowledge of the document’s schema.

      dateToEpochConversion

      deepCloneAndModify

      removeObjectStubs

      removeNullsAndEmptys

      genericRename

      genericFlatten

      convertXMLtoJSON

      convertAdvXMLtoJSON

      Advanced Accessor Eventing Functions: The following Scriptlets demonstrate using Advanced Bucket Accessors (introduced in version 6.6.1) which allow the use of CAS, ability to set expirations (or TTLs) and the use of distributed atomic counters to increment or decrement counts.

      advancedGetOp

      advancedGetOpWithCache

      advancedInsertOp

      advancedUpsertOp

      advancedReplaceOp

      advancedDeleteOp

      advancedIncrementOp

      advancedDecrementOp

      advancedKeepLastN

      advancedDocControlledSelfExpiry

      multiCollectionEventing

      Binary Document Support: The following Scriptlets demonstrate support for binary documents in Eventing. Only a Function with “language compatibility” of 6.6.2 or above in its settings will pass binary documents to the OnUpdate(doc,meta) handler.

      basicBinaryKV

      advancedBinaryKV

      Performance Eventing Functions The following Scriptlets are performance oriented and/or benchmarks.

      fasterToLocalString