A newer version of this documentation is available.

View Latest

Adding a Couchbase Function

    To add a new Function, proceed as follows:
    1. From the Couchbase Web Console > Eventing page, click ADD FUNCTION.

    2. In the ADD FUNCTION dialog, for individual Function elements provide the below information:

      Table 1. Add a Function Dialog
      Elements Description

      Source Bucket

      The name of a bucket currently defined on the cluster.

      For more information on creating buckets, refer to Create a Bucket

      Metadata Bucket

      The name of a bucket currently defined on the cluster. This bucket stores artifacts and checkpoint information.

      Function Name

      A name, for the Function you are creating.


      A description of the Function you are creating. This is optional.


      The available settings are:

      • Log Level: The granularity at which messages are logged. The options (available from the arrows control at the right of the field) are Info, Error, Warning, Debug, and (the default). This logging attribute is function-specific and is not applicable for the Eventing Service in general.

      • Workers: The number of worker threads to be allocated to the Function. The default is 3.

      • Script Timeout: The number of seconds that should elapse before the script times out. The default is 60.


      One or more strings, each of which is used as a reference to an existing bucket, from within the JavaScript code of your Function.

      For more information on Bindings, refer to Bindings.

    3. Click Next: Add Code. The Function name dialog appears. The Function name dialog initially contains a placeholder code block. You will substitute your actual Function code in this block.

    4. To return to the Eventing screen, click Eventing.

    5. Click on the Function name. Additional controls are now displayed: The controls are:

      • Delete: Deletes the Function from the system.

      • Export: Exports the Function as a JSON document.

      • Deploy: Deploys the Function, making it active across the cluster.

      • Edit JavaScript: Allows edits to be made on the Function, in an edit dialog.

    6. Click Deploy. This displays the Confirm Deploy Function dialog. The Feed Boundary determines whether documents previously in existence needs to be included in the Function’s activities: the options are Everything and From now. The Everything option invokes a Function on all mutations available in the cluster. The From now option invokes a Function during future instances of data mutation, post Function deployment.

    7. Click Deploy Function. This deploys the Function and returns you to the main Eventing screen. The display indicates that the Function is now deployed and running. From this point, your defined Function will run, first, on all existing documents; and subsequently, whenever a creation or mutation occurs.

    8. Click Undeploy to undeploy a Function.