MongoDB¶
AMI supports MongoDB datasources, although this is not offered as a default option. If you require the MongoDB datasource adapter, please contact us at support@3forge.com.
Setting up the Adapter¶
-
Unzip the MongoDB files assigned to you from the client portal and add them to your AMI library in
amione/lib. -
Add the following line to your
local.propertiesfile ensuring to reference the existing datasource plugin list ($${ami.datasource.plugins}): -
Restart AMI. MongoDB should now be available under Dashboard -> Data Modeler -> Attach Datasource.
-
Give your MongoDB Datasource a name and configure the URL. The URL should take the following format:
Note
If you receive the connection error "code 18", change the URL to contain the following:
Additional Parameters¶
Your MongoDB datasource may be configured such that you need to pass in additional parameters, e.g: authentication.
- To set these different MongoDB parameters, add the parameters to the MongoDB URL as a query string:
-
- To pass multiple parameters, delimit each key-value pair with an "&":
-
Querying MongoDB¶
The AMI MongoDB adapter can query a MongoDB datasource and output SQL tables. The general syntax for querying MongoDB is:
This can be done in any field that takes AmiScript.
Collections¶
Assuming you have collections established in MongoDB, you can query these tables in AMI.
For a trivial example, consider a collection, zipcodes, with the following properties in MongoDB:
Then query this table in AMI:
Collections with Nested Fields¶
AMI supports querying of MongoDB collections with nested fields. Consider the collection myAccounts with nested fields in the address field:
To query this table in AMI, call the nested field from its parent field using dotconcatentation:
Using EVAL Methods (Deprecated)¶
Previously, AMI MongoDB methods were supported using FROM EVAL functionality. This has since been deprecated. Instead, AMI supports the following directives directly:
The general format for using MongoDB commands involves encapsulating your MongoDB sort command in a string followed by the AMIScript EXECUTE statement:
MongoDB Directives Examples¶
The result of running the different supported MongoDB directives in AMI on a toy datamodel results in the following output:
Sort¶
This creates two tables, userSorted and accountsSorted with users sorted in alphabetical order, followed by city name in descending order.
Find¶
To find a given field, create a table in AMI then use the _find directive:
This query will return a table with entries from a collection for a user named "Crouton."
Skip¶
To skip documents, create an AMI table with a MongoDB skip condition:
Where in the last example, the first row where age is less than or equal to 11 is skipped.


