Retrieving records by using a LoopBackRequest node

Use a LoopBackRequest node in a message flow to retrieve data records through a LoopBack® connector such as MongoDB, Cloudant®, or PostgreSQL.

Before you begin

Complete the tasks in the following topics:

About this task

You retrieve records by specifying Retrieve in the Operation property of the LoopBackRequest node. You can retrieve all records of a particular type by specifying the object type in the LoopBack object property of the node. This object type can be overridden by a value specified in the LocalEnvironment.Destination.Loopback.Request.object local environment variable.

Alternatively, you can retrieve a specific record by specifying an ID in the LocalEnvironment.Destination.Loopback.Request.id environment variable. The returned record appears as a JSON object in the location that is specified by the Output data location property of the node.

If an external ID name and value are specified in the LocalEnvironment.Destination.Loopback.Request.externalIdName and LocalEnvironment.Destination.Loopback.Request.externalId environment variables, all records with that external ID are returned. The returned records appear as a JSON array in the location specified by the Output data location property.

You can control the records that are returned by using the LocalEnvironment.Destination.Loopback.Request.filter environment variable to specify a filter with the following clauses:
  • where
  • limit
  • skip
  • order
  • field
If your installed LoopBack connector supports additional capabilities beyond those provided by these filter options, you can use the filterString local environment variable instead of filter. If both filter and filterString are specified, filterString takes precedence. For more information, see Filtering the records retrieved through a LoopBack connector.
By default, the retrieval of records is determined by the following properties, in order of precedence:
  • ID
  • External ID
  • Filter

If no records are found, the output tree contains nothing under JSON.data.

If you have configured a model for use with your LoopBack connector, see Using models with LoopBack connectors, for additional information.

Procedure

Follow these steps to retrieve records by using a LoopBackRequest node:

  1. Create a flow containing a LoopBackRequest node, and set the following properties on the Basic tab:
    1. In the Data source property, specify the name of the data source stanza for your chosen connector in the LoopBack datasources.json file.
    2. In the Operation property, specify Retrieve.
    3. In the LoopBack object property, select the type of object that you want to retrieve.
    4. In the Security identity property, specify the security identity that you will use when connecting to the LoopBack application. For information about configuring the security identity on the integration node, see Specifying security credentials for connecting to a secured data source.
    5. In the Timeout (milliseconds) property, specify the time (in milliseconds) that the node waits for the LoopBack connector to process the operation.

    These properties can be overridden dynamically in the flow, as described in Using local environment variables with LoopBackRequest nodes. For more information about the LoopBackRequest node properties, see LoopBackRequest node.

  2. Send the required message through the flow to the LoopBack application.
    The node emits the JSON data of the record, which can be an empty message if no record is found. The message will be in the JSON domain and can be created and processed by any suitable transformation node. To use the Mapping node, you must provide a message model of the data, as described in Creating or transforming a JSON message by using a JSON schema.
  3. Check that the records have been retrieved correctly.
    You can also check the activity log for additional information about events related to the LoopBackRequest node. If the Loopback operation was not successful, the node reports by raising an exception with a BIP message that might include an error returned from the installed LoopBack connector. If the failure terminal is connected, the node will propagate the exception list to it, otherwise the flow will roll back.