A newer version of this documentation is available.

View Latest

Function: Advanced GET operation

    March 23, 2025
    + 12

    Goal: Perform the Advanced GET operation where Eventing interacts with the Data service.

    • This function advancedGetOp merely demonstrates the Advanced GET operation.

    • Requires Eventing Storage (or metadata collection) and a "source" collection.

    • Needs a Binding of type "bucket alias" (as documented in the Scriptlet).

    • Will operate on any mutation where doc.type === "test_adv_get".

    • For more information refer to Advanced GET operation in the detailed documentation.

    javascript
    // To run configure the settings for this Function, advancedGetOp, as follows: // // Version 7.1+ // "Function Scope" // *.* (or try bulk.data if non-privileged) // Version 7.0+ // "Listen to Location" // bulk.data.source // "Eventing Storage" // rr100.eventing.metadata // Binding(s) // 1. "binding type", "alias name...", "bucket.scope.collection", "Access" // "bucket alias", "src_col", "bulk.data.source", "read and write" // // Version 6.6.1 // "Source Bucket" // source // "MetaData Bucket" // metadata // Binding(s) // 1. "binding type", "alias name...", "bucket", "Access" // "bucket alias", "src_col", "source", "read and write" function OnUpdate(doc, meta) { // filter out non-intersting documents if (!doc.type || doc.type !== "test_adv_get") return; log('input doc ', doc); log('input meta', meta); // let's read the same item and then try to read a non existent item var meta_ary = [{"id":"test_adv_get::1"}, {"id":"not_present::1"}]; for (var i = 0; i < meta_ary.length; i++) { var result = couchbase.get(src_col,meta_ary[i]); if (result.success) { log('success adv. get: result',result); } else { log('failure adv. get: id',meta_ary[i].id,'result',result); } } }