Transport map for MongoDB Insert

The MongoDB Insert transport map allows you to insert JSON documents into a MongoDB database collection. You have the ability to provide multiple JSON documents to the transport map in the following ways:

  • As an input array of strings with each array element containing a JSON document 
  • Specify a JSON template that the transport map will use to build JSON documents from input variables.

Assumptions

The following is assumed:

Procedure

To define an insert 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 insert operation from the Operations pick list. The panel changes as shown below.

  4. If you are specifying JSON documents as an input array define an input parameter with a datatype of STRING. Specify the count value that represents the maximum number of JSON documents that will be provided to this transport map from a trigger.

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

    Parameter Description
    Collection The collection name that the documents will be inserted into. You can either type the name or select a collection from the pick list.
    Write Concern The write concern that will be used when inserting a document into the collection. You can specify one of the following options from the pick list
    • none ( default )
    • acknowledged
    • journalled
    • majority
    • unacknowledged
    • W1
    • W2
    • W3
    Payload Type Specifies how the document will be provided to the transport map. Select one of the following:
    • Array - The documents will be provided in an Input tab array variable of type 'String'
    • JSON - The JSON documents will be built by the transport map based on a template specified by the user and values provided by Input tab variables.
  6. Specifying a Payload Type of Array 
    • Select the input variable from the Input Array pick list.
  7. Specifying a Payload Type of JSON

    • When you select a payload type of JSON, the panel changes to 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.  
    • In order to specify multiple documents to be inserted, change the count of the input variables to be greater than 1.

  8. Define a trigger that uses the previously defined insert transport map with a payload type of Array.  You can use the inputCount  input variable to specify how many items are being provided. If left unspecified the count value (array size) is used.

  9. The figure below shows an example of a trigger using an insert transport map with a payload type of JSON.  You can use the inputCount variable to specify how many items in the array are being provided. If left unspecified the array size is assumed to be 1 and only one document will be inserted.