> Markdown versions of all pages of this connector library are available by appending `.md` to the page URL. For the full index of connectors, see [llms.txt](https://connectors.appmixer.com/llms.txt).

# appmixer.mongodb.db.UpdateDocument

- Component: `appmixer.mongodb.db.UpdateDocument`
- Kind: Action
- Version: 1.0.0
- Visibility: Public
- Connector: [appmixer.mongodb 1.4.1](https://connectors.appmixer.com/connector/appmixer.mongodb/1.4.1.md)
- Component page: <https://connectors.appmixer.com/connector/appmixer.mongodb/1.4.1/component/appmixer.mongodb.db.UpdateDocument>

Update a document(s) in a MongoDB collection.

## Input ports

### Port `in`

| Field | Type | Description |
| --- | --- | --- |
| Collection (`collection`) | text | Enter your collection name. |
| Document ID (`id`) | text | Document ID. If **Document ID** is given, then the **Update filter** cannot be used. |
| Update filter (`filter`) | textarea | The filter used to select the document to update. If **Update filter** is used, then **Document ID** cannot be specified. |
| Document (`document`) | textarea | The update operations to be applied to the document. |
| Upsert (`upsert`) | toggle | When true, creates a new document if no document matches the query. |
| One/Many (`quantity`) | select | Update a single document in a collection or update multiple documents in a collection. |

## Output ports

### Port `out`

| Field | Type | Description |
| --- | --- | --- |
| Document (`document`) | object | - |
| Acknowledged (`acknowledged`) | boolean | - |
| Matched Count (`matchedCount`) | integer | - |
| Modified Count (`modifiedCount`) | integer | - |
| Upserted Count (`upsertedCount`) | integer | - |
| Upserted Id (`upsertedId`) | string | - |

## Full metadata (component.json)

```json
{
  "name": "appmixer.mongodb.db.UpdateDocument",
  "author": "Harsha Surisetty <harsha@client.io>",
  "description": "Update a document(s) in a MongoDB collection.",
  "private": false,
  "version": "1.0.0",
  "auth": {
    "service": "appmixer:mongodb"
  },
  "inPorts": [
    {
      "name": "in",
      "schema": {
        "type": "object",
        "properties": {
          "collection": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "filter": {
            "type": "string"
          },
          "document": {
            "type": "string"
          },
          "upsert": {
            "type": "boolean"
          },
          "quantity": {
            "type": "string"
          }
        },
        "oneOf": [
          {
            "required": [
              "id"
            ]
          },
          {
            "required": [
              "filter"
            ]
          }
        ],
        "required": [
          "collection",
          "document"
        ]
      },
      "inspector": {
        "inputs": {
          "collection": {
            "type": "text",
            "index": 1,
            "label": "Collection",
            "tooltip": "Enter your collection name."
          },
          "id": {
            "type": "text",
            "index": 2,
            "label": "Document ID",
            "tooltip": "Document ID. If <b>Document ID</b> is given, then the <b>Update filter</b> cannot be used."
          },
          "filter": {
            "type": "textarea",
            "index": 3,
            "label": "Update filter",
            "tooltip": "The filter used to select the document to update. If </b>Update filter</b> is used, then <b>Document ID</b> cannot be specified."
          },
          "document": {
            "type": "textarea",
            "index": 4,
            "label": "Document",
            "tooltip": "The update operations to be applied to the document."
          },
          "upsert": {
            "type": "toggle",
            "index": 5,
            "defaultValue": true,
            "label": "Upsert",
            "tooltip": "When true, creates a new document if no document matches the query."
          },
          "quantity": {
            "type": "select",
            "index": 6,
            "label": "One/Many",
            "tooltip": "Update a single document in a collection or update multiple documents in a collection.",
            "defaultValue": "One",
            "options": [
              {
                "content": "One",
                "value": "One"
              },
              {
                "content": "Many",
                "value": "Many"
              }
            ]
          }
        }
      }
    }
  ],
  "outPorts": [
    {
      "name": "out",
      "options": [
        {
          "label": "Document",
          "value": "document",
          "schema": {
            "type": "object",
            "example": {
              "id": "64a7f2c9e4b0d1a2b3c4d5e6",
              "name": "John Doe",
              "email": "john.doe@example.com"
            }
          }
        },
        {
          "label": "Acknowledged",
          "value": "acknowledged",
          "schema": {
            "type": "boolean",
            "example": true
          }
        },
        {
          "label": "Matched Count",
          "value": "matchedCount",
          "schema": {
            "type": "integer",
            "example": 1
          }
        },
        {
          "label": "Modified Count",
          "value": "modifiedCount",
          "schema": {
            "type": "integer",
            "example": 1
          }
        },
        {
          "label": "Upserted Count",
          "value": "upsertedCount",
          "schema": {
            "type": "integer",
            "example": 0
          }
        },
        {
          "label": "Upserted Id",
          "value": "upsertedId",
          "schema": {
            "type": "string",
            "example": "64a7f2c9e4b0d1a2b3c4d5e6"
          }
        }
      ]
    }
  ],
  "icon": "(data URI omitted)"
}
```
