mongodbtrigger

package
v0.0.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 Trigger

This activity allows you to listen for Create, Update and Delete Document events in a single collection or all collections in a MongoDb database.

Installation

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

Configuration

Settings:
Name Type Description
connection connection Choose a MongoDB connection from the drop down - REQUIRED
Handler Settings
Name Type Description
databaseName string MongoDB Database name - REQUIRED
collectionName string The collection to listen to for changes. If left blank, listens to all collections in a DB
listenInsert bool Should the trigger listen to Insert events?
listenUpdate bool Should the trigger listen to Update events?
listenRemove bool Should the trigger listen to Remove events?
Output:
Name Type Description
output object A JSON object of key value pairs containing the information about the MongoDB event that the trigger is configuerd to listen

Example

The below example shows the values for MongoDB Trigger in the Flogo app JSON as well as the connection object referenced by the trigger. The MongoDB trigger listens to all events of a collection called test in a MongoDB database named sample

"triggers": [
  {
    "ref": "github.com/project-flogo/datastore-contrib/mongodb/trigger/mongodb",
    "name": "mongodb-trigger",
    "description": "",
    "settings": {
      "connection": "conn://a7730ae0-0199-11ea-9e1b-1b6d6afda988"
    },
    "id": "MongoDBTrigger",
    "handlers": [
      {
        "description": "",
        "settings": {
          "databaseName": "sample",
          "collectionName": "test",
          "listenInsert": true,
          "listenUpdate": true,
          "listenRemove": true
        },
        "action": {
          "ref": "github.com/project-flogo/flow",
          "settings": {
            "flowURI": "res://flow:nov8tr"
          },
          "input": {
            "output": "=$.output"
          }
        },
        "schemas": {
          "output": {
            "output": {
              "type": "json",
              "value": "{\"$schema\":\"http://json-schema.org/draft-04/schema#\",\"type\":\"object\",\"definitions\":{},\"properties\":{\"NameSpace\":{\"type\":\"object\"},\"OperationType\":{\"type\":\"string\"},\"ResultDocument\":{\"type\":\"object\"}}}",
              "fe_metadata": "{\"$schema\":\"http://json-schema.org/draft-04/schema#\",\"type\":\"object\",\"definitions\":{},\"properties\":{\"NameSpace\":{\"type\":\"object\"},\"OperationType\":{\"type\":\"string\"},\"ResultDocument\":{\"type\":\"object\"}}}"
            }
          }
        }
      }
    ]
  }
]

"connections": {
  "a7730ae0-0199-11ea-9e1b-1b6d6afda988": {
    "id": "a7730ae0-0199-11ea-9e1b-1b6d6afda988",
    "name": "mc2",
    "ref": "github.com/project-flogo/datastore-contrib/mongodb/connection",
    "settings": {
      "name": "mc2",
      "description": "",
      "connectionURI": "<Connection URI Here>",
      "credType": "<One of None or SCRAM-SHA-1 or SCRAM-SHA-256>",
      "username": "<Enter Username here in case of SCRAM-SHA-1 or SCRAM-SHA-256>",
      "password": "",
      "ssl": false,
      "x509": false,
      "trustCert": "",
      "clientCert": "",
      "clientKey": "",
      "keyPassword": "",
      }
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory(md *trigger.Metadata) trigger.Factory

NewFactory create a new Trigger factory

Types

type EventListener

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

EventListener is structure of a single EventListener

type HandlerSettings

type HandlerSettings struct {
	Database     string `md:"databaseName,required"` // MongoDB Database name
	Collection   string `md:"collectionName"`        // The collection to listen to for changes. If left blank, listens to all collections in a DB
	ListenInsert bool   `md:"listenInsert,required"` // Should the trigger listen to Insert events?
	ListenUpdate bool   `md:"listenUpdate,required"` // Should the trigger listen to Update events?
	ListenRemove bool   `md:"listenRemove,required"` // Should the trigger listen to Remove events?
}

HandlerSettings structure

type Output

type Output struct {
	Output map[string]interface{} `md:"output"` //The Output of the trigger
}

Output structure

func (*Output) FromMap

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

FromMap method for Output

func (*Output) ToMap

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

ToMap method for Output

type Settings

type Settings struct {
	Connection string `md:"connection,required"` // The MongoDB connection
}

Settings structure

type Trigger

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

Trigger is a stub for your Trigger implementation

func (*Trigger) Initialize

func (t *Trigger) Initialize(ctx trigger.InitContext) error

Initialize Mongodb Event Listener

func (*Trigger) Metadata

func (t *Trigger) Metadata() *trigger.Metadata

Metadata implements trigger.Trigger.Metadata

func (*Trigger) Start

func (t *Trigger) Start() error

Start implements trigger.Trigger.Start

func (*Trigger) Stop

func (t *Trigger) Stop() error

Stop implements trigger.Trigger.Stop

type TriggerFactory

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

TriggerFactory My Trigger factory

func (*TriggerFactory) Metadata

func (*TriggerFactory) Metadata() *trigger.Metadata

Metadata implements trigger.Factory.Metadata

func (*TriggerFactory) New

func (t *TriggerFactory) New(config *trigger.Config) (trigger.Trigger, error)

New Creates a new trigger instance for a given id

Jump to

Keyboard shortcuts

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