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.
You can parameterize the MongoDB V2 target connection and target object with values specified in a parameter file when you configure a mapping or a mapping in advanced mode.
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 Objects1
  • - 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.
When you use an existing target, you can select one of the following schema options:
  • - Infer schema from the selected target object2. Select only when you read primitive data types.
  • - Generate the schema for the target object from the incoming fields to the Target transformation1. Select when you read primitive or hierarchical data types.
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
  • - Data Driven2
Default is Insert.
Update Columns
The primary key column to update, upsert, or delete data in a MongoDB target.
This property appears when you select Update, Delete, Upsert, or Data Driven as the operation type.
If you do not specify a primary key column, the mapping considers the target column that you configured as the primary key column to update, upsert, or delete data.
Data Driven Condition2
Enables you to define expressions that flag rows for an insert, update, upsert, or delete operation.
This property appears only when you select Data Driven as the operation type.
You need to specify the data driven condition for non-CDC sources. For CDC sources, you need to leave the field empty as the rows in the CDC source tables are already marked with the operation types.
1 Applies only to mappings in advanced mode.
2Doesn't apply 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.

Pass-through partitioning

You can configure pass-through partitioning along with other target properties when you write data to MongoDB V2 targets.
The pass-through partitioning method controls how the agent distributes data among partitions at partition points. You can define the partition type as pass-through partitioning. With partitioning, the agent distributes rows of target data based on the number of threads that you define as partition.
You can't use pass-through partitioning for mapping tasks that are based on mappings in advanced mode.
For more information about partitions, see Transformations.

Rules and guidelines for MongoDB V2 target transformations

Consider the following guidelines for MongoDB V2 target transformations: