Using components: MongoDB Source

In the MongoDB Source component, you define the parameters and credentials for accessing data in a MongoDB document database and which fields you will use in your package.

Source components are always the first components in a package.

source settings
  1. Define the parameters for connecting to your MongoDB collection as follows (for more information, see Allow Xplenty access to my MongoDB):
    • mongodb connection - either click the drop-down arrow and select an existing connection, or click (create new) to create a new connection.
    • source collection - the collection name to extract data from.
    • filter query - use MongoDB extended JSON to apply a filter on MongoDB's server side, or leave empty to query the entire collection. Note that $ is a special character that denotes a variable, so it must be escaped by a single back-slash in your extended JSON filter. For example:

      {"age":{"\$gt":24}}  - extract all documents where age is greater than 24.

      {"\$or":[{"price":{"\$exists":false}},{"price":{"\$eq":0}}]} - extract all documents where price is zero or does not exist.

      {"timestamp":{"\$gt":{"\$date":"2014-01-01T00:00:00.000Z"}}} - extract all documents where timestamp is greater than the date value 2014-01-01T00:00:00.000Z

Then click the Test Connection button to help check that the connection is good and that the source collection exists.

document mapping

  1. After defining the source settings, use the green Auto-detect Schema button to get the field names and data types, or the blue Show data preview button to preview the data and fill in the fields manually.
  2. Define the document keys you want to extract from the collection as follows:
    • Define the key in the document.
    • Define the alias you will use for the document key as a field in the data-flow.
    • Define the data type for the field. Use the following table when matching MongoDB data types to Xplenty data types.
MongoDB Xplenty
String String
32 Bit Integer Integer
64 Bit Integer Long
Double Double
Date DateTime
Object Json
Array Json Array
Boolean Boolean
ObjectID String

Feedback and Knowledge Base