removeDocument

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: 11 Imported by: 0

README

MongoDB Remove Document

This activity allows you to remove one or more documents from a collection in MongoDb database based on a matching criteria entered as a JSON

Installation

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

Configuration

Settings:
Name Type Description
connection connection Choose a MongoDB connection from the drop down - REQUIRED
operation string The Query operation type (Remove One Document or Remove Many Documents) - REQUIRED
databaseName string MongoDB databse to remove documents - REQUIRED
collectionName string The collection within the MongoDB database to remove documents - REQUIRED
timeout int32 Timeout in seconds for the activity's operations
Input:
Name Type Description
criteria object The matching criteria entered as a JSON - In case an empty JSON is provided and if operation is Remove Many Documents, all the documents in the collection will be removed
Output:
Name Type Description
deletedCount int64 Returns the total deleted documents

Example

The below example shows the values for MongoDB Remove Document activity in the Flogo app JSON as well as the connection object referenced by the activity. The MongoDB Remove Document activity in this example deletes all the documents in a collection that has a key called 'location' with value' Palo Alto'

{
  "id": "MongoDBRemoveDocument1",
  "name": "MongoDBRemoveDocument1",
  "description": "Mongodb Remove Document activity",
  "activity": {
    "ref": "#removeDocument",
    "settings": {
      "connection": "conn://a7730ae0-0199-11ea-9e1b-1b6d6afda988",
      "operation": "Remove Many Documents",
      "databaseName": "sample",
      "collectionName": "deletetesting",
      "timeout": "20"
    },
    "input": {
      "criteria": {
        "location": "Palo Alto"
      }
    }
  }
}

"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 New

New functioncommon

Types

type Activity

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

Activity is a stub for your Activity implementation

func (*Activity) Cleanup

func (a *Activity) Cleanup() error

func (*Activity) Eval

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

Eval implements activity.Activity.Eval

func (*Activity) Metadata

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

Metadata implements activity.Activity.Metadata

type Input

type Input struct {
	Input interface{} `md:"criteria,required"` // The JSON Request Object that will serve as search parameter for deciding which documents to delete
}

Input structure

func (*Input) FromMap

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

FromMap method

func (*Input) ToMap

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

ToMap method

type Output

type Output struct {
	DeletedCount int64 `md:"deletedCount"` // A number indicating total Documents that were deleted by this activity

}

Output structure

func (*Output) FromMap

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

FromMap Output

func (*Output) ToMap

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

ToMap Output

type Settings

type Settings struct {
	Connection     string `md:"connection,required"`                                                   // The MongoDB connection
	Operation      string `md:"operation,required,allowed(Remove One Document,Remove Many Documents)"` // Operation to perform
	CollectionName string `md:"collectionName,required"`                                               // The collection within the MongoDB database to Remove Documents
	Database       string `md:"databaseName,required"`                                                 // MongoDB databse to Remove Documents
	Timeout        int32  `md:"timeout"`                                                               // Timeout in seconds for the activity's operations
}

Settings structure

Jump to

Keyboard shortcuts

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