Examples: Using the Eventing Service

    March 23, 2025
    + 12

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

    Step-by-Step Examples

    Detailed Examples

    The following tutorial-like guides have detailed start-to-finish instructions and are ideal for new users to learn the basics of the Eventing Service.

    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

    Basic SQL++ Eventing Functions

    The following scriptlets demonstrate how to use SQL++ or the Query Service with an Eventing Function.

    basicN1qlSelectStmt

    basicN1qlPreparedSelectStmt

    Generic Manipulation Eventing Functions

    The following scriptlets are examples of advanced use cases that focus on mutating a document without knowing that document’s schema.

    dateToEpochConversion

    deepCloneAndModify

    removeObjectStubs

    removeNullsAndEmptys

    genericRename

    genericFlatten

    convertXMLtoJSON

    convertAdvXMLtoJSON

    Advanced Accessor Eventing Functions

    The following scriptlets demonstrate how to use Advanced Keyspace Accessors, which allow you to:

    • Use CAS

    • Set expiry (TTL) dates

    • Use distributed atomic counters to increment and decrement counts

    advancedGetOp

    advancedGetOpWithCache

    advancedInsertOp

    advancedUpsertOp

    advancedReplaceOp

    advancedDeleteOp

    advancedIncrementOp

    advancedDecrementOp

    advancedTouchOp

    advancedKeepLastN

    advancedDocControlledSelfExpiry

    multiCollectionEventing

    advancedSelfRecursion

    advancedMutateInField

    advancedMutateInArray

    advancedLookupInField

    Binary Document Support

    The following scriptlets demonstrate support for binary documents in Eventing.

    Your Eventing Function must have a language compatibility setting of Couchbase Server version 6.6.2 or above to pass binary documents in its OnUpdate(doc,meta) handler.

    basicBinaryKV

    advancedBinaryKV

    Performance Eventing Functions

    The following scriptlets are examples of performance-oriented or benchmark Eventing Functions.

    fasterToLocalString