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:
- You are familiar with JSON
- You are familiar with specifying a FreeForm transport map as described in Creating a payload of freeform text
- You are familiar with defining a JSON transport map as described in Transport Map for a JSON format request
- You are familiar with the MongoDB Query syntax
- A MongoDB transport has been created.
Procedure
To define a find transport map, access a node with the Workbench.
- Navigate to the Transport Map window and select the
New button.
- 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.
- Select the find operation from the
Operations pick list. The panel
changes as shown below.
-
Specify optional input variables that will be used in building the Query string.
-
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. - 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.
- 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.
-
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.
- 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.