Transport map for MongoDB Update

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

  • Specify a collection to work with
  • Specify a query document that can be customized by input variables to identify documents to be updated
  • Specify whether to modify or replace the matched documents
  • Specify an update directive as a JSON document.

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 the MongoDB Update syntax
  • A MongoDB transport has been created.

Procedure

To define a update 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 update 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 and Update 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.
    Write Concern The write concern that will be used when updating documents in the collection. You can specify one of the following options from the pick list
    • none ( default )
    • acknowledged
    • journalled
    • majority
    • unacknowledged
    • W1
    • W2
    • W3
    On Match Specify what the update query should do with the documents found
    • modify (default) - Update the documents that were found with the query specified in the Update tab
    • replace - Replace the documents that were found with the JSON document specified in the Update tab
    Documents Specify how many documents will be modified
    • one - Update the first document that was found
    • multiple (default) - Update all documents that were found
    Upsert Specify if the Upsert option is enabled or disabled (default).
    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.
  6. Specify content in the To Enterprise Update tab as shown in the image below. The update tab is a free form text box where you can build a JSON string that specifies the update. 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.



  7. Define a trigger that uses the previously defined update transport map. The image shows the output tab of this action.

    The output tab of the update Transaction action will display the following output variables. These variables are updated with the results of the execution of the update operation. If you select none or unacknowledged for the WriteConcern parameter, then these values will not be updated.

    Parameter Description
    resultStatus The result of executing the update transaction. If successful this will be 0.
    resultCount The number of documents that were updated.
    failureCount The number of documents that could not be updated.
    upsertedId If the Upsert option was enabled this returns the identifier of the 'upserted' document.
    matchedCount The number of documents that matched the query criteria.