You can use the MongoDB adapter to interact with a MongoDB and to insert, get and manipulate documents.
Using one of the find operations from the MongoDB adapter, you can retrieve data. MongoDB stores data in form of documents that are depicted in a JSON-like format. Queries always return one or more complete documents.
MongoDBAdapter_CustomerData_Example
Click the icon to download a simple example model that shows the usage of the MongoDB adapter in Scheer PASDesigner.
For all actions that refer to existing documents, you need to provide a query string (queryString) to identify them. A query string contains all properties of the document you want to use for selection.
Assume we have the following sample Customer document structure:
MongoDB uses the concept of "projection" to define which properties should be selected from a document. The projection is supplied to the adapter call via the projection attribute of the MongoDBFindOptions.
The following rules apply to projections:
Rule
Example
You can select dedicated properties.
{ name: 1 }
You can select all properties and omit dedicated properties.
{ name: 0 }
You cannot mix both above mentioned rules. This will lead to an exception.
{ name: 1, company: 0 }
You can select properties from within a structure.
{ address.street: 1 }
You cannot select all properties and omit dedicated properties from within a structure. This will be ignored.
{ address.street: 0 }
Sorting
You can sort the document list you get back from an adapter call by providing the sort attribute of MongoDBFindOptions. Parameter sort contains the document properties to sort by. Value 1 is ascending sorting, value -1 is descending sorting. The order of JSON properties reflects the sort hierarchy.
create options;
set options.`sort` = "{\"company\":1,\"orderVolume\":-1}";
You can also create a class defining the sort options, and use classToExtendedJSON() to create the sort string.
You need to escape the attribute name of sort because there is an operation having the same name.