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

> The MongoDB sink connector pulls messages from Pulsar topics and persists the messages to collections.

# Mongodb sink

The MongoDB sink connector pulls messages from Pulsar topics and persists the messages to collections.

# Configuration

The configuration of the MongoDB sink connector has the following properties.

## Property

| Name          | Type   | Required | Sensitive | Default            | Description                                                                                                                                                                          |
| ------------- | ------ | -------- | --------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `mongoUri`    | String | true     | true      | " " (empty string) | The MongoDB URI to which the connector connects. <br /><br />For more information, see [connection string URI format](https://docs.mongodb.com/manual/reference/connection-string/). |
| `database`    | String | true     | false     | " " (empty string) | The database name to which the collection belongs.                                                                                                                                   |
| `collection`  | String | true     | false     | " " (empty string) | The collection name to which the connector writes messages.                                                                                                                          |
| `batchSize`   | int    | false    | false     | 100                | The batch size of writing messages to collections.                                                                                                                                   |
| `batchTimeMs` | long   | false    | false     | 1000               | The batch operation interval in milliseconds.                                                                                                                                        |

## Example

Before using the Mongo sink connector, you need to create a configuration file through one of the following methods.

* JSON

  ```json theme={null}
  {
      "mongoUri": "mongodb://localhost:27017",
      "database": "pulsar",
      "collection": "messages",
      "batchSize": "2",
      "batchTimeMs": "500"
  }
  ```

* YAML

  ```yaml theme={null}
  {
      mongoUri: "mongodb://localhost:27017"
      database: "pulsar"
      collection: "messages"
      batchSize: 2
      batchTimeMs: 500
  }
  ```
