The MongoDB extractor allows you to fetch data from the NoSQL MongoDB database. Supported MongoDB versions are from 4.4 to latest (6.0). 4.2 could work also, but not guaranteed. Lower version are not supported by version of mongoexport. Complete the following steps to configure it.
Click the New Export button and configure your first export using the following options:
Name – Identifies your export; its value has to be unique across all exports and exported tables in your configuration. Also, the main exported table will be named after the value of the Name field.
Collection – Represents the collection name in your MongoDB database.
Query (optional) – JSON string specifying a query which limits documents data in exported data. Must be specified in a strict format.
Sort (optional) – JSON string specifying the order of documents in exported data. Must be specified in a strict format.
Limit (optional) – Limits the number of exported documents.
Incremental – Loads data to your tables incrementally.
Mode – Specifies the export mode: Mapping or Raw. Start by exporting few documents using the Raw mode first – it will help you see the document structure for which you need to write mapping.
Mapping – This is the most important section in case you have selected the Mapping mode; it defines how documents in the collection are mapped to the output tables. It, too, has to be valid JSON.
Tip: Use a combination of a limit (for example, only 10 documents) and a query (for example, only a document with specific ID) while playing with the mapping section to prevent a full collection export.
By defining mapping, you specify the structure and content of your output tables, their columns and relations between them.
Tip: Export few documents using the Raw Export Mode first – it will help you see the document structure (in Strict Format) for which you need to write mapping.
Since MongoDB identifies each document in a collection uniquely by
_id, we recommend to set
a primary key to this field by defining the first item in a mapping section:
Note: The destination column with the primary key should be named
_id to prevent problems with
the data import.
To handle MongoDB data types correctly, define mapping similarly to the following example for
NumberLong data types.
|Document in Strict Mode
Check out more mapping examples.
In the raw export mode, documents are exported as plain JSON strings.
|Document in Strict Mode