Skip to main content

MongoDB

This connector materializes data from your Flow collections to your MongoDB collections.

ghcr.io/estuary/materialize-mongodb:dev provides the latest connector image. You can also follow the link in your browser to see past image versions.

Data model

MongoDB is a NoSQL database. Its data model consists of documents (lightweight records that contain mappings of fields and values) organized in collections. MongoDB documents have a mandatory _id field that is used as the key of the collection. Flow collection documents are materialized as MongoDB documents with an _id field value based on the Flow collection key.

info

If your Flow collection already has a field named _id, its value will be present in the materialized MongoDB document as the field _flow_id to prevent conflicts with the required _id field.

Prerequisites

You'll need:

  • Credentials for connecting to your MongoDB instance and database.

  • Read and write access to your MongoDB database and desired collections. See Role-Based Access Control for more information.

  • If you are using MongoDB Atlas, or your MongoDB provider requires allowlisting of IPs, you need to allowlist the Estuary IP addresses.

Configuration

You configure connectors either in the Flow web app, or by directly editing the Flow specification file. See connectors to learn more about using connectors. The values and specification sample below provide configuration details specific to the Firestore source connector.

Properties

Endpoint

PropertyTitleDescriptionTypeRequired/Default
/addressAddressHost and port of the database. Optionally can specify scheme for the URL such as mongodb+srv://host.stringRequired
/databaseDatabaseName of the database to capture from.stringRequired
/userUserDatabase user to connect as.stringRequired
/passwordPasswordPassword for the specified database user.stringRequired

Bindings

PropertyTitleDescriptionTypeRequired/Default
/collectionStreamCollection namestringRequired
/delta_updatesDelta UpdateShould updates to this table be done via delta updates.booleanfalse

Sample

materializations:
${PREFIX}/${CAPTURE_NAME}:
endpoint:
connector:
image: ghcr.io/estuary/materialize-mongodb:dev
config:
address: "mongo:27017"
database: "test"
password: "flow"
user: "flow"
bindings:
- resource:
collection: users
database: test
source: ${PREFIX}/users

SSH Tunneling

As an alternative to connecting to your MongoDB instance directly, you can allow secure connections via SSH tunneling. To do so:

  1. Refer to the guide to configure an SSH server on the cloud platform of your choice.

  2. Configure your connector as described in the configuration section above, with the addition of the networkTunnel stanza to enable the SSH tunnel, if using. See Connecting to endpoints on secure networks for additional details and a sample.

Delta updates

This connector supports both standard (merge) and delta updates. The default is to use standard updates.