Transport map for MongoDB Find

The MongoDB Find transport map allows you to find JSON documents in a MongoDB database collection. You have the ability to do the following:

  • Specify a collection to work with
  • Specify a query criteria that can be customized by input variables
  • Specify projection and sort documents
  • Specify the range of documents with a starting index and a maximum number of documents  
  • Specify how to map content from the documents to output variables 
    • As an input array of strings with each array element containing a JSON document 
    • As a JSON template that will be used to parse returned documents into output variables.

Assumptions

The following is assumed:

Procedure

To define a find transport map, access a node with the Workbench.

  1. Navigate to the Transport Map window and select the New button.
  2. In the Transport Name parameter, select a MongoDB transport. You can use the Transport Type parameter to filter the transports listed to a specific transport type.
  3. Select the find operation from the Operations pick list. The panel changes as shown below.

  4. Specify optional input variables that will be used in building the Query string.

  5. Specify content in the To Enterprise section using the table below.

    Parameter Description
    Collection The collection name to be used when searching for documents. You can either type the name or select a collection from the the pick list.
    Read Concern The read concern that will be used when finding documents in the collection. You can specify one of the following options from the pick list:
    • none ( default )
    • local
    • majority
    Documents Select one of the following from the pick list:
    • one - The transport map will return the first document from the set of queried documents
    • multiple - The transport map will return multiple documents from the set of queried documents
    Skip Count Specify the number of documents to be skipped after the set of documents has been queried.
    Document Limit if the Documents selection is multiple, this count specifies the maximum number of documents after the skip count that will be processed.
    Payload Type Specifies how the document found by the query criteria will be processed by the transport map. Select one of the following:
    • Array - The documents will be returned in an Output tab array variable of type 'String'
    • JSON - The JSON documents will be parsed by the transport map based on a template specified by the user and assigned to Output tab variables.
    To Enterprise tab
    Query A free form text box where you can build a JSON document that defines the query. You can use input variables as substitution values. Refer to Creating a payload of freeform text for details on specifying a free form text with input variables.
    Projection A text box where you can specify the JSON document that describes the projection.
    Sort A text box where you can specify the JSON document that describes the sort criteria.
  6. Specify how the document data will be mapped in the From Enterprise tab. This panel will change based on the selection made in the Payload Type field.
    • Payload Type: Array. An Output Array pick list will be displayed where you will select a previously defined output variable with a datatype of String. The count should match the number specified in the Document Limit field. The image below shows an example. 

    • Payload Type: JSON.
      • The panel will allow for the specification of a JSON payload as shown in the image below
      • Refer to Transport Map for a JSON format request for step by step instructions on defining a JSON payload
      • The output variables should have a count that matches the number specified in the Document Limit field.

  7. Define a trigger that uses the previously defined find transport map with a payload type of Array. The outputCount variable in the output tab will contain the number of documents that were found. The resultStatus output variable will contain the overall status of the execution of the transport map.

  8. The figure below shows an example of a trigger using a find transport map with a payload type of JSON.  The outputCount variable in the output tab will contain the number of documents that were found and processed. The resultStatus output variable will contain the overall status of the execution of the transport map.