> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zwiron.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MongoDB Connector

> Sync MongoDB collections with full refresh or incremental into Snowflake, BigQuery, and warehouses via Zwiron.

<Info>
  **Live — enterprise connector.** Fully supported today (SAT-validated). One of Zwiron's five production connectors: PostgreSQL, MySQL, MongoDB, Snowflake, BigQuery.
</Info>

|                 |                                |
| --------------- | ------------------------------ |
| **Source**      | ✅                              |
| **Destination** | ✅                              |
| **CDC**         | ✅ (via Change Streams)         |
| **Sync modes**  | Full Refresh, Incremental, CDC |

***

## Connection settings

| Field              | Description                                                                                                                 |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------- |
| **Connection URI** | MongoDB connection string: `mongodb://user:pass@host:27017/db`                                                              |
| **Database**       | Target database name. Must be filled in manually — some providers (e.g. Railway) omit the database from the connection URL. |
| **Auth source**    | Authentication database (default: `admin`)                                                                                  |
| **TLS**            | Enable TLS for encrypted connections                                                                                        |

For MongoDB Atlas, use the connection string from **Database** → **Connect** → **Connect your application**.

For **Railway**, the `MONGO_PUBLIC_URL` variable does not include a database name. Enter the database name manually in the **Database** field — Railway will create it automatically on first use if it doesn't already exist.

***

## Permissions

```js theme={null}
db.createUser({
  user: "zwiron",
  pwd: "password",
  roles: [
    { role: "read", db: "your_database" },
    { role: "read", db: "local" }  // required for CDC change streams
  ]
})
```

For CDC, the user also needs access to the `local` database and change stream privilege.

***

## CDC via Change Streams

MongoDB change streams require a **replica set** or **sharded cluster** — standalone instances do not support change streams.

For MongoDB Atlas, all clusters run as replica sets by default.

For self-hosted MongoDB, initialize a replica set:

```
rs.initiate()
```

***

## Document flattening

MongoDB documents can have nested fields. Enable [Flatten](/concepts/transforms#flatten) in your pipeline transforms to expand nested fields into top-level destination columns.

***

## Troubleshooting

**`unescaped @ sign in user info`** — Your password contains a special character (e.g. `@`, `:`, `/`, `#`, `?`) that conflicts with the URI format. Percent-encode the character in your connection string:

| Character | Encoded |
| --------- | ------- |
| `@`       | `%40`   |
| `:`       | `%3A`   |
| `/`       | `%2F`   |
| `#`       | `%23`   |
| `?`       | `%3F`   |

Example: if your password is `p@ssword`, use `p%40ssword` in the URI:

```
mongodb+srv://user:p%40ssword@host/db
```

***

## Notes

* MongoDB 4.0+ is required for change streams (CDC)
* ObjectId fields are converted to strings
* Arrays are serialized as JSON strings at the destination unless flattened
