queryDocument

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

README

MongoDB Query Document

This activity allows you to query for 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/queryDocument

Configuration

Settings:
Name Type Description
connection connection Choose a MongoDB connection from the drop down - REQUIRED
operation string The Query operation type (Find One Document or Find Many Documents) - REQUIRED
databaseName string MongoDB databse to query - REQUIRED
collectionName string The collection within the MongoDB database to query - REQUIRED
timeout int32 Timeout in seconds for the activity's operations
Input:
Name Type Description
criteria object The matching criteria entered as a JSON
Output:
Name Type Description
output any Returns a single JSON object for Find One Document operation or returns an array of JSON objects in case of Find Many Documents operation

Example

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

{
  "id": "MongoDBQueryDocument",
  "name": "MongoDBQueryDocument",
  "description": "Mongodb Query Document activity",
  "activity": {
    "ref": "github.com/project-flogo/datastore-contrib/mongodb/activity/queryDocument",
    "settings": {
      "connection": "conn://a7730ae0-0199-11ea-9e1b-1b6d6afda988",
      "operation": "Find One Document",
      "databaseName": "sample",
      "collectionName": "test",
      "timeout": 0
    },
    "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

Cleanup method

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 the query
}

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 {
	Output interface{} `md:"response"` // The JSON Response for Querying one or more documents from a collection
}

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(Find One Document,Find Many Documents)"` // Operation to perform
	CollectionName string `md:"collectionName,required"`                                           // The collection within the MongoDB database to query
	Database       string `md:"databaseName,required"`                                             // MongoDB databse to query
	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