Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Figure 1 shows the MongoDB properties without enabling the Show Expert Properties check box.


Figure 1: MongoDB Component Configuration CPS

Connection Configuration

Click the Connection Configuration ellipsis button to set up the configuration required to connect to MonogDB server.


Figure 2: Connection Configuration dialog box

Database Host(s)

A list of primary and secondary (if present) database servers' host and port details in the form of <host>:<port> can be provided here.

...

Connection Timeout (in ms)

The timeout in milliseconds until a connection is established. If the A value is zero, the timeout is not used0 means no timeout.

Connection String

Additional Connection String to specify additional connection options. Each connection option is specified as a pair in the following form: name=value.

Note
  • The value is case sensitive.
  • Separate the options with ampersand (&) character.
Tip

For a complete list of connection string options, please refer to the following link:
https://docs.mongodb.com/manual/reference/connection-string/#connections-connection-options

Query Configuration

Click the Query Configuration ellipsis button to set up the configuration required to add queries.


Figure 3: Query Configuration dialog box

Any of the CRUD operations can be configured by clicking the Add button and selecting the required operation name from the menu. A Query with default Query Name and Query Type is added to the list of queries.

...

Type of QueryDescription

INSERT

Inserts data into database collection

BULKINSERTInserts multiple rows of data documents into database collection

UPDATE

Modifies existing data in the database collection

DELETE

Deletes data from the database collection

SELECT

Retrieves data from the database collection

...

This button deletes all the queries in the query list. 

INSERT

Image RemovedImage Added
Figure 4: Insert Query Configuration

Right-click the empty space in the element-type table to add a key to insert the required field in the document.

 Image RemovedImage Added
Figure 5: Adding a new field to elementElement-type Type table.

Image RemovedImage Added
Figure 6: Right click Context menu on a field in the Element-Type Tabletable

Add Child: Adds a node to the parent node. Refer to http://docs.mongodb.org/manual/tutorial/model-tree-structures-with-child-references/ for further details.

...

Delete: The selected field will be deleted on clicking this button.
Image Removed
Image Added
Figure 7: Adding children to a parent node in the Element-Type Table

This structure will generate a document of the form {"key1": {"child1":"val", "child2":"val"}, "key2" : "val"}.

Refer to section "Input and output" for further details about the input.

Image RemovedImage Added
Figure 8: Up-Down buttons to change the order of elements

Up: Moves the selected field above the previous field.

Down: Moves the selected field below the next field. 

...

BULKINSERT

Image RemovedImage Added
Figure 9:
Update Query ConfigurationBulk Insert Query configuration

This operation is used to insert multiple documents into a collection. A JSON array can be specified to list the documents to be inserted.

Refer to Input and Output section for the sample input and its output. In the Query Configuration window, provide a Collection name, and set JSON to "true" so that JSON array can be specified in the input to insert multiple documents into the specified collection.

UPDATE

Image Added
Figure 10: Update Query configuration

Fields present in the first element-type-operator are updated if conditions specified in the second table are met.

...

Note

 Equality is considered by default when none of the operators are chosen.

DELETE

Image RemovedImage Added
Figure 1011: Delete Query Configuration 

...

For further information, go through the "input and output" section.

SELECT

Image RemovedImage Added
Figure 1112: Select Query Configuration \configuration

The condition for the operation is to be specified in the Select Condition table. Fields to be retrieved should be specified in the Select Fields table. 

...

We have many types of arrays like String[],Object[],Boolean[],Int[] etc which are to be selected from the cps to specify operations on that particular type.

Int []

Image RemovedImage Added
Figure 1213: Input to insert array an array of type int[]

Input schema

...

Array with "key" : [ 123, 321, 456, 789 ] is added into the collection.

Output Type

JSONDisplays the output in the form of a JSON string.

XMLDisplays the output in XML format.

 

Functional Demonstration

Connect a Feeder component to insert input to the MongoDB component and add a Display component to display the output.


Figure 1314: Sample flow of MongoDB

Input and Output

...

Insert operation Input Schemas for different JSON values are given below. 

...

JSON set to false

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<ns1:MongoRequest xmlns:ns1="http://www.fiorano.com/MONGODB/MongoDB1">
   <ns1:Insert>
      <ns1:name>abc</ns1:name>
   </ns1:Insert>
</ns1:MongoRequest>

...

JSON set to true

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<ns1:MongoRequest xmlns:ns1="http://www.fiorano.com/MONGODB/MongoDB1">
   <ns1:Insert>{name:"abc"}</ns1:Insert>
</ns1:MongoRequest>

Output for the Insert operation


Figure 1415: Output for insert the Insert operation

Input for Bulk Insert operation

JSON set to true

Code Block
<ns1:BulkInsert>
   [
{ "name" : "abc" },
{ "name" : "def" },
{ "name" : "ghi" }
]
</ns1:BulkInsert>

Output for Bulk Insert Operation

This will insert three documents into the collection specified in Query Configuration window.

Image Added
Figure 16: Output for the Bulk Insert operation

Input for the Update operation

Update operation Input Schemas for different JSON values are given below. 

...

JSON set to false

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<ns1:MongoRequest xmlns:ns1="http://www.fiorano.com/MONGODB/MongoDB1">
   <ns1:Update>
      <ns1:Condition>
         <ns1:qty>70</ns1:qty>
      </ns1:Condition>
      <ns1:Fields>
         <ns1:type>juice</ns1:type>
      </ns1:Fields>
   </ns1:Update>
</ns1:MongoRequest>

...

JSON set to true

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<ns1:MongoRequest xmlns:ns1="http://www.fiorano.com/MONGODB/MongoDB1">
   <ns1:Update>
      <ns1:Condition>{qty:{$gt:70}}</ns1:Condition>
      <ns1:Fields>{type:"juice"}</ns1:Fields>
   </ns1:Update>
</ns1:MongoRequest>

...

Output for the Update operation


Figure 1517: Output for the update Update operation

Input for the Delete operation

Delete operation Input Schemas for different JSON values are given below. 

...

JSON set to false

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<ns1:MongoRequest xmlns:ns1="http://www.fiorano.com/MONGODB/MongoDB1">
   <ns1:Delete>
      <ns1:name>abc</ns1:name>
   </ns1:Delete>
</ns1:MongoRequest>

...

JSON set to true

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<ns1:MongoRequest xmlns:ns1="http://www.fiorano.com/MONGODB/MongoDB1">
   <ns1:Delete>{name:"abc"}</ns1:Delete>
</ns1:MongoRequest>

Output for the Delete operation


Figure 1618: Output for delete the Delete operation

Input for the Select operation

Select operation Input Schemas for different JSON values are given below. 

...

JSON set to false

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<ns1:MongoRequest xmlns:ns1="http://www.fiorano.com/MONGODB/MongoDB1">
   <ns1:Select>
      <ns1:qty>70</ns1:qty>
   </ns1:Select>
</ns1:MongoRequest>

...

JSON set to true

Code Block
<?xml version="1.0" encoding="UTF-8"?>
<ns1:MongoRequest xmlns:ns1="http://www.fiorano.com/MONGODB/MongoDB1">
   <ns1:Select>
      <ns1:Condition>{qty:{$gt:70}}</ns1:Condition>
      <ns1:Fields>{type:" "}</ns1:Fields>
   </ns1:Select>
</ns1:MongoRequest>

Displays the "_id" and "type" fields in the documents which has have "qty" field greater than 70.

Empty An empty value in the fields section retrieves all the fields in the documents which are satisfying the condition.

Output for the Select operation


Figure 1719: Output for select Select operation

Points to note

  • Select output type XML for Insert, Update and Delete operations and JSON for Select operation for the ease of use.
  • While inserting fields of 'Date' data type, please ensure that the date is in the following format to avoid exceptions:

    Code Block
    yyyy-MM-dd'T'HH:mm:ssZ

    Info
    titleExample
    • "2018-09-25T17:09:58+0000" is a valid format.
    • "2018-09-25T17:09:58" is not a valid format.
Adaptavist ThemeBuilder EngineAtlassian Confluence