MongoDB V2 Connector > Mappings for MongoDB V2 > MongoDB V2 targets in mappings
  

MongoDB V2 targets in mappings

To write data to a MongoDB V2 target, configure a MongoDB V2 object as a Target transformation in a mapping.
Specify the name and description of a MongoDB V2 target.
The following table describes the target properties that you can configure for a MongoDB V2 target:
Property
Description
Connection
Name of the MongoDB V2 connection that is associated with a dataset.
You can select an existing connection or create a new connection. You can also click New Parameter to define a parameter for the target connection.
Target Type
Type of the target object.
Select one of the following options:
  • - Single Object
  • - Multiple Objects¹
  • - Parameter
Object
Name of the MongoDB V2 target object based on the target type selected.
Existing
You can select an existing MongoDB V2 target table to write data.
You can infer schema from the selected target object.
You can generate schema from the incoming fields when you read primitive or hierarchical data types for mappings in advanced mode.
Create New at Runtime
Creates a MongoDB V2 target table at runtime based on the target table you specify.
To create a target table at runtime, enter the name of the target table that you want to create in the Object Name field.
The agent creates the target table based on the object name and the path you specify. You can edit the metadata of the source fields before creating the target.
When you create a new target at run time and the target already exists, the mapping appends the data to the existing target.
Operation
Type of the target operation.
Select from one of the following operations:
  • - Insert
  • - Update
  • - Delete
  • - Upsert
¹ Applies only to mappings in advanced mode.
The following table describes the advanced properties that you can configure in a Target transformation:
Property
Description
Update Mode
Defines how rows are updated in the target tables.
Select from the following options:
  • - Update As Update: Rows matching the selected update columns are updated in the target.
  • - Update Else Insert: Rows matching the selected update columns are updated in the target. Rows that don't match are appended to the target.
Pre Query
Statement that you want to run before writing data to the target.
You can use only insert, update, and delete operations.
For example, if you want to insert records in the database before you read the records from the table, specify the following preSQL statement:
{ insert: 'yourCollection', documents: [ { name: 'Alice', age: 25 } ] }
Post Query
Statement that you want to run after writing data to the target.
You can use only insert, update, and delete operations.
For example, if you want to update records in a table after you read the records from a table, specify the following postSQL statement:
{ update: 'yourCollection', updates: [ { q: { name: 'Alice' }, u: { $set: { age: 26 } } } ] }
Additional Properties
Additional options that you want to specify to write data to MongoDB. Separate multiple options with an ampersand.
For information about the additional properties that you can configure, see the Configure additional properties chapter.
Forward Rejected Rows
Determines whether the transformation passes rejected rows to the next transformation or drops rejected rows.
By default, the agent forwards rejected rows to the next transformation.

Rules and guidelines for MongoDB V2 target transformations

Consider the following guidelines for MongoDB V2 target transformations: