MongoDB
Supermetal's MongoDB integration leverages MongoDB's native change streams capability to provide efficient, reliable data extraction with minimal impact on your database. This integration enables both initial snapshot capture and continuous replication of changes through a strongly-typed schema approach.
This guide covers the features, prerequisites, and configuration steps required to connect MongoDB with Supermetal.
Features
| Feature | Notes | 
|---|---|
| Initial Data Sync | |
| Change Data Capture | |
| Schema Evolution | |
| Catalog Support | |
| Document Flattening | 
Prerequisites
Before you begin, ensure you have:
- 
MongoDB Requirements:
- Version: MongoDB 4.0 or higher (required for change streams support)
 - Supported Deployments:
MongoDB Community/Enterprise Server(replica set configuration)MongoDB Atlas
 
Change Streams Requirement
Change streams require a replica set deployment. If you're using a standalone server, you must convert it to a single-node replica set to use change streams.
 - 
Deployment Requirements:
- Replica Set: Your MongoDB deployment must be configured as a replica set
 - Read Concern Majority: Supermetal uses read concern "majority" to ensure consistent reads
 - Database Permissions: User with appropriate permissions (see Setup)
 - Network Connectivity: Ensure Supermetal can reach your MongoDB deployment (default port: 27017)
 - TLS/SSL Support: Supermetal supports both unencrypted and TLS/SSL encrypted connections
 
 - 
MongoDB Atlas Requirements:
- Network Access: Configure network access rules to allow Supermetal to connect
 - Connection String: Use the connection string format that includes all replica set members
 
 
Setup
Permissions Overview
Supermetal requires a dedicated MongoDB user with appropriate permissions to read data and access change streams. The recommended approach is to create a dedicated read-only user.
| MongoDB Deployment | Minimum Required Permissions | 
|---|---|
| Self-managed | read role on the mongo database to replicate from | 
| MongoDB Atlas | readAnyDatabase role | 
Create a Dedicated Read-Only MongoDB User
Connect to your MongoDB instance using the mongo shell with admin privileges:
mongosh --host <host> --port <port> -u <admin-username> -p <admin-password> --authenticationDatabase adminScript Variables
Replace the placeholder values in the command with your actual information:
<host>: Your MongoDB server hostname or IP address<port>: MongoDB port (default is 27017)<admin-username>: Username with admin privileges<admin-password>: Password for the admin user
Create a dedicated user for Supermetal:
use admin
db.createUser({
  user: "supermetal_user",
  pwd: "strong-password",
  roles: [
    { role: "read", db: "target-database" }
  ]
})Script Variables
Replace the placeholder values in the script with your actual information:
strong-password: Replace with a secure, unique password for thesupermetal_user.target-database: The name of the database you want to replicate from.
Log in to your MongoDB Atlas account
Visit cloud.mongodb.com to access your account.
Data Types Mapping
Supermetal automatically maps MongoDB BSON types to Apache Arrow data types according to the following mapping:
| MongoDB BSON Type(s) | Apache Arrow DataType | Notes | 
|---|---|---|
Double | Float64 | |
Int32 | Int32 | |
Int64 | Int64 | |
Decimal128 | Utf8 | Preserved as string to maintain exact precision and handle MongoDB's variable decimal precision/scale requirements | 
| MongoDB BSON Type(s) | Apache Arrow DataType | Notes | 
|---|---|---|
DateTime | Timestamp(Millisecond) | |
Timestamp | Timestamp(Millisecond) | MongoDB internal timestamp type | 
| MongoDB BSON Type(s) | Apache Arrow DataType | Notes | 
|---|---|---|
String | Utf8 | |
Symbol | Utf8 | Deprecated MongoDB type | 
RegularExpression | Utf8 | Converted to string representation | 
JavaScriptCode | Utf8 | Converted to string representation | 
JavaScriptCodeWithScope | Utf8 | Converted to string representation | 
| MongoDB BSON Type(s) | Apache Arrow DataType | Notes | 
|---|---|---|
Boolean | Boolean | 
| MongoDB BSON Type(s) | Apache Arrow DataType | Notes | 
|---|---|---|
Array (same data type) | List<ElementType> | Only for arrays with homogeneous element types | 
Array (different data types) | Json | Heterogeneous arrays are converted to JSON | 
Document | Json | Nested documents represented as JSON | 
| MongoDB BSON Type(s) | Apache Arrow DataType | Notes | 
|---|---|---|
Binary | Utf8 | Encoded as hexadecimal string for lossless representation and compatibility | 
| MongoDB BSON Type(s) | Apache Arrow DataType | Notes | 
|---|---|---|
ObjectId | Utf8 | Converted to hex string representation | 
DbPointer | Utf8 | Legacy MongoDB type | 
Null | Null | Represented as null in target columns | 
MinKey | Utf8 | Special MongoDB comparison type | 
MaxKey | Utf8 | Special MongoDB comparison type | 
Undefined | Utf8 | Deprecated MongoDB type | 
Last updated on



