# MongoDB

Write messages from NATS to a MongoDB collection.

## Configuration

| Name          | Type   | Optional | Secret | Description                                                                                                                                                                                                                                                                                                                                         |
| ------------- | ------ | -------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| url           | string | no       | no     | The MongoDB connection URL.                                                                                                                                                                                                                                                                                                                         |
| database      | string | no       | no     | The name of the database to query.                                                                                                                                                                                                                                                                                                                  |
| collection    | string | no       | no     | The name of the collection to query.                                                                                                                                                                                                                                                                                                                |
| document_map  | string | no       | no     | A bloblang map representing a document to store within MongoDB, expressed as extended JSON in canonical form. The document map is required for the operations insert-one, replace-one and update-one.                                                                                                                                               |
| filter_map    | string | yes      | no     | A bloblang map representing a filter for a MongoDB command, expressed as extended JSON in canonical form. The filter map is required for all operations except insert-one. It is used to find the document(s) for the operation. For example in a delete-one case, the filter map should have the fields required to locate the document to delete. |
| operation     | string | yes      | no     | The operation to perform on the collection. The value should be one of `insert-one`, `delete-one`, `delete-many`, `replace-one` or `update-one`. The value defaults to `insert-one`.                                                                                                                                                                |
| upsert        | bool   | yes      | no     | Whether to perform an upsert operation. The value defaults to `false`.                                                                                                                                                                                                                                                                              |
| max_in_flight | int    | yes      | no     | The maximum number of messages to have in flight at a given time. Increase this to improve throughput. The value defaults to `1024`.                                                                                                                                                                                                                |
