# README


title: MongoDB weight: 4622

MongoDB

This activity allows you to connect to a MongoDB server

Installation

Flogo CLI

flogo install github.com/TIBCOSoftware/flogo-contrib/activity/mongodb

Schema

Inputs and Outputs:

{
  "input": [
    {
      "name": "uri",
      "type": "string",
      "required": true
    },
    {
      "name": "dbName",
      "type": "string",
      "required": true
    },
    {
      "name": "collection",
      "type": "string",
      "required": true
    },
    {
      "name": "method",
      "type": "string",
      "allowed": [
        "DELETE",
        "INSERT",
        "REPLACE",
        "UPDATE"
      ],
      "value": "INSERT",
      "required": true
    },
    {
      "name": "keyName",
      "type": "string"
    },
    {
      "name": "keyValue",
      "type": "string"
    },
    {
      "name": "value",
      "type": "any"
    }
  ],
  "output": [
    {
      "name": "output",
      "type": "any"
    },
    {
      "name": "count",
      "type": "integer"
    }
  ]
 }

Settings

SettingRequiredDescription
uriTrueThe MongoDB connection URI
dbNameTrueThe name of the database
collectionTrueThe collection to work on
methodTrueThe method type (DELETE, INSERT, UPDATE or REPLACE). This field defaults to INSERT
keyNameFalseThe name of the key to use when looking up an object (used in DELETE, UPDATE, and REPLACE)
keyValueFalseThe value of the key to use when looking up an object (used in DELETE, UPDATE, and REPLACE)
valueFalseThe value of the object (used in INSERT, UPDATE, and REPLACE)

Example

The below example is for an insert into MongoDB

{
  "id": "MongoDB_1",
  "name": "MongoDB connector",
  "description": "Insert MongoDB documents in a specified collection",
  "activity": {
    "ref": "github.com/TIBCOSoftware/flogo-contrib/activity/mongodb",
    "input": {
      "uri": "mongodb://localhost:27017",
      "dbName": "mydb",
      "collection": "users",
      "method": "INSERT",
      "value": {"name":"theuser"}
    }
  }
}

# Functions

NewActivity creates a new AppActivity.

# Structs

Integration with MongoDb inputs: {uri, dbName, collection, method, [keyName, keyValue, value]} outputs: {output, count} */.