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

# MongoDB Sink

> Write job results to a MongoDB collection via the sink service

The MongoDB Sink command (Command Type: 1204) sends the job result to the sink service, which writes it to a MongoDB collection.

## Command Type

**Command Type ID:** 1204

## Parameters

| Parameter             | Type   | Description                                                                                   | Required |
| --------------------- | ------ | --------------------------------------------------------------------------------------------- | -------- |
| **collection**        | string | The MongoDB collection where documents will be written                                        | Yes      |
| **dataSegmentToSend** | string | Which part of the data to send. Possible values: `"fullData"`, `"data"`. Defaults to `"data"` | Yes      |
| **operation**         | string | Whether to always insert a new document or replace a matched document                         | Yes      |

## Usage Examples

### Insert into MongoDB

```json theme={null}
{
  "command": "mongodb-sink",
  "params": {
    "collection": "events",
    "dataSegmentToSend": "data",
    "operation": "insert"
  }
}
```

### Upsert (Replace) by Match Key

```json theme={null}
{
  "command": "mongodb-sink",
  "params": {
    "collection": "live_odds",
    "dataSegmentToSend": "data",
    "operation": "upsert"
  }
}
```

## Related Commands

* [Kafka Sink](/stream/commands/sink/kafka-sink) - Publish to Kafka
* [S3 Sink](/stream/commands/sink/s3-sink) - Upload to S3
* [RabbitMQ Sink](/stream/commands/sink/rabbitmq-sink) - Publish to RabbitMQ
