MongoDB Writer Feature Type Parameters
To access feature type parameters, click the gear icon on a feature type in the workspace to open the Feature Type Parameter Editor. To always display the editor in Workbench, you can select View > Windows > Parameter Editor.
All feature types share similar General Parameters. This includes Name and Writer Name. From here, you can also control Dynamic Properties.
These parameters apply only to a selected feature type, not to the entire writer.
Tip: If a feature type parameter listed here conflicts with a writer-level parameter, then the writer parameter will be ignored and this feature type parameter will be used.
Table: General
This parameter specifies how features will be written into the destination table. Supported feature operations are described below. Note that the described behavior can be dependent on the selected options, as well as the underlying table properties.
Option |
Description |
If the Row Does Not Exist |
If the Row Exists |
---|
Insert | The writer appends a new row to a table using input feature attributes and/or geometries. | The writer creates a new row using input feature attributes and/or geometries. |
Not always applicable: if the table does not have a unique key or it has an automatically generated unique key, insertion is always possible. The database cannot violate its key constraints; therefore, errors can occur on row insertion. For example, if there is a unique key and a user specifies the value with the feature, and the feature already exists, then Workbench logs an error. This error might be in the form of a rejected feature, or the database may stop processing altogether. |
Put |
The writer appends a new row to a table using input feature attributes and/or geometries. If a row with the same primary identifier already exists, the existing row is overwritten by the new row. A selection method must be specified in the Row Selection group. |
The writer creates a new row using input feature attributes and/or geometries. |
The writer deletes the existing row corresponding to the input feature and appends a new row using input feature attributes and/or geometries. |
fme_db_ operation |
The feature operation will be determined by the attribute fme_db_operation on each input feature. A selection method must be specified in the Row Selection group. The value of fme_db_operation will be processed as follows, depending on available options:
Note about earlier FME versions: To use fme_db_operation, you must set Feature Operation to this option. In previous versions of FME, you could set fme_db_operation when the destination feature type was set to Insert, Update, or Delete. Doing this now will cause feature rejection. |
The action depends on the operation; however, in general, if nothing is specified, the value is treated as Insert. | The value is treated as Insert. |
This parameter controls how the feature type handles destination tables. These options are available:
- Create If Needed: Create destination table if it does not exist. The writer uses the information within the FME workspace to automatically create Vector Feature tables as required. All tables will be created when the first input feature is processed. If no features are sent to a feature type, then the corresponding table will not be created.
- Drop and Create: Drop destination table if it exists, then create it. The writer will drop and re-create the table before writing any features to it. Tables will be overwritten when the first input feature is processed. If no features are sent to a feature type, then the corresponding table will not be overwritten.
When Feature Operation is set to Insert, Row Selection is ignored. When Feature Operation is set to Put or fme_db_operation, a condition needs to be specified for selecting which documents to operate on. This parameter group includes the following method to construct the selection condition:
- ID Attribute: The value of this attribute will be matched to the value of the _id field of an existing document. This field uniquely identifies the document.
Collection Creation Parameters
Specifies the name of the geometry field to be created.
This parameter is only relevant if Table Handling is set to Create if Needed or Drop and Create, and the collection is being created.
If set to Yes, Workbench will create a 2dsphere spatial index on the collection.
This parameter is only relevant if if Table Handling is set to Create if Needed or Drop and Create, and the collection is being created.
Advanced
The source of JSON documents to write to the database.
- Feature: Documents will be created from features sent to the writer (which is the usual behavior).
- JSON Attribute: Documents will be created using JSON directly from an attribute, if possible.
This parameter is enabled when the Document Source is Feature. It can be used to specify an attribute to use as the Document ID.
Value: 24-character hexadecimal string
Any features that contain that attribute will use its value as the JSON Document ID.
This parameter is enabled when the Document Source is JSON Attribute. It can be used to specify an attribute to use directly as the document JSON. Any features that contain the JSON attribute will be written using the JSON attribute value. Other features will be written as usual.