mongodb

package module
v0.1.1-0...-51b37bf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: BSD-3-Clause Imports: 10 Imported by: 0

README

MongoDb

This activity allows you to Get, Insert, Update and Delete a document in MongoDb database.

Installation

Flogo CLI
flogo install github.com/project-flogo/datastore-contrib/activity/mongodb

Configuration

Settings:
Name Type Description
uri string The MongoDB connection URI - REQUIRED
method string The method type (GET, INSERT, UPDATE or DELETE) - REQUIRED
dbName string The name of the database - REQUIRED
collection string The collection to work on - REQUIRED
username string The username of the client
password string The password of the client
Input:
Name Type Description
keyName string The name of the key to use when looking up an object (used in GET, UPDATE and DELETE)
keyValue string The value of the key to use when looking up an object (used in GET, UPDATE, and DELETE)
data object The bson document to insert in mongodb
Output:
Name Type Description
output any The result of the MongoDB method invocation

Example

The below example allows you to configure the activity to reply and set the output values to literals "name" (a string) and 2 (an integer).

{
  "id": "flogo-mongodb",
  "name": "MongoDb",
  "description": "MongoDb Activity",
  "activity": {
    "ref": "github.com/project-flogo/datastore-contrib/activity/mongodb",
    "settings": {
      "uri" : "localhost:27017",
      "method" : "INSERT",
      "dbName" : "test",
      "collection" : "example"
    },
    "input" : {
        "keyName" : "foo",
        "keyValue" : "bar"
    }
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

Types

type Activity

type Activity struct {
	// contains filtered or unexported fields
}

func (*Activity) Cleanup

func (a *Activity) Cleanup() error

func (*Activity) Eval

func (a *Activity) Eval(ctx activity.Context) (done bool, err error)

Eval implements api.Activity.Eval - Logs the Message

func (*Activity) Metadata

func (a *Activity) Metadata() *activity.Metadata

Metadata returns the activity's metadata

type Input

type Input struct {
	KeyName  string      `md:"keyName"`  // The name of the key to use when looking up an object (used in GET, UPDATE and DELETE)
	KeyValue string      `md:"keyValue"` // The value of the key to use when looking up an object (used in GET, UPDATE, and DELETE)
	Data     interface{} `md:"data"`     // The bson document to insert in mongodb
}

func (*Input) FromMap

func (i *Input) FromMap(values map[string]interface{}) error

func (*Input) ToMap

func (i *Input) ToMap() map[string]interface{}

type Output

type Output struct {
	Data interface{} `md:"data"`
}

func (*Output) FromMap

func (o *Output) FromMap(values map[string]interface{}) error

func (*Output) ToMap

func (o *Output) ToMap() map[string]interface{}

type Settings

type Settings struct {
	URI        string `md:"uri,required"`                                      // The MongoDB connection URI
	Method     string `md:"method,required,allowed(GET,INSERT,UPDATE,DELETE)"` // The method type
	DbName     string `md:"dbName,required"`                                   // The name of the database
	Collection string `md:"collection, required"`                              // The collection to work on
	Username   string `md:"username"`                                          // The username of the client
	Password   string `md:"password"`                                          // The password of the client
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL