Help Center/ FunctionGraph/ User Guide/ Creating Triggers/ Using a GeminiDB Mongo Trigger
Updated on 2024-08-15 GMT+08:00

Using a GeminiDB Mongo Trigger

This section describes how to create and configure a GeminiDB Mongo trigger for a function.

A function using a GeminiDB Mongo trigger will be triggered every time a database table is updated. For details about the GeminiDB Mongo event source, see Supported Event Sources.

Prerequisites

Before creating a trigger, ensure that you have prepared the following:

Creating a GeminiDB Mongo Trigger

  1. Log in to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
  2. Click the function to be configured to go to the function details page.
  3. Choose Configuration > Triggers and click Create Trigger.

    Figure 1 Creating a trigger

  4. Set the following parameters:

    • Trigger Type: Select GeminiDB Mongo.
    • GeminiDB Mongo Instance: Select a GeminiDB Mongo instance.
    • Password: Enter the password of the GeminiDB Mongo instance administrator rwuser.
    • Database: Enter the name of a GeminiDB Mongo database. Note that admin, local, and config are reserved database names and cannot be used here.
    • Collection: Enter the name of a database collection.
    • Batch Size: Set the number of records to be read from the database at a time.

  5. Click OK.

    After VPC access is enabled, you need to configure corresponding subnet permissions for the GeminiDB Mongo security group. For details about how to configure VPC access, see Configuring the Network.

Configuring a GeminiDB Mongo Event to Trigger the Function

  1. Return to the FunctionGraph console. In the navigation pane, choose Functions > Function List.
  2. Click the function to be configured to go to the function details page.
  3. On the function details page, select a version.
  4. On the Code tab page, click Test. The Configure Test Event dialog box is displayed.
  5. Set the parameters described in Table 1 and click Save.

    Table 1 Test event information

    Parameter

    Description

    Configure Test Event

    You can choose to create a test event or edit an existing one.

    Use the default option Create new test event.

    Event Template

    Select GeminiDB Mongo.

    Event Name

    The event name can contain 1 to 25 characters and must start with a letter and end with a letter or digit. Only letters, digits, underscores (_), and hyphens (-) are allowed. For example, geminimongo-123test.

    Event data

    The system automatically loads the built-in GeminiDB Mongo event template, which is used in this example without modifications.

  6. Click Test. The function test result is displayed.