DataLayer.Mongo Map Reduce
MongoDB is a cross-platform, document-oriented database system, classified as a "NoSQL" database. Rather than using a traditional table-based, relational DB structure, it uses a collection of JSON-like documents with variable schemas. The DataLayer.Mongo Map Reduce element runs a Mongo Map Reduce command designed to return one or more documents.
- Attributes
- Working with DataLayer.Mongo Map Reduce
General information about MongoDB can be found at the official website.
Attributes
The DataLayer.Mongo Map Reduce element has the following attributes:
Working with DataLayer.Mongo Map Reduce
The Mongo map-reduce operation is used to condense large volumes of data into useful aggregated results, and this element incorporates that functionality into its data retrieval process.
In many respects, DataLayer.Mongo Map Reduce functions exactly as other datalayer elements do and, once retrieved, its data can be filtered and conditioned using appropriate child elements. Like other datalayers, it works with a specific Connection element, Connection.MongoDB, to connect to the datasource.
As shown above, the Connection.MongoDB element is added to the _Settings definition, beneath the Connections element. Attributes are set appropriately for the MongoDB datasource. A Mongo Params element is available for use beneath Connection.MongoDB to supply additional options when connecting to the MongoDB database. Examples of additional parameters include "connectTimeoutMS" and "maxPoolSize". Refer to the MongoDB connection options documentation for a the complete list of options.
Next, in the report definition, a DataLayer.Mongo Map Reduce element is added as a child element of a Data Table or another data container element. Its attributes are set so that it accesses the desired MongoDB connection and data collection.
MongoDB results are often hierarchical and may consist of multiple levels of parent-child relationships. In order to work with Logi elements, the data often must be "tabularized" and this can be done by using The Flattener element.
The datalayer reads and caches the data from the datasource. You can add standard child elements beneath the datalayer to affect its contents, including:
- Filtering: Sort, group, or restrict the data
- Extending: Add virtual columns to the datalayer that contain aggregated, calculated, or totaled data values
- Securing: Limit access to the data using Logi security
- Linking: Make the results reusable elsewhere in your report definitions
Data read into the datalayer is cached in XML format in memory and/or on the web server's file system. The latter is discussed in The Logi Server Engine and may be of interest to developers working with extremely large datasets or large numbers of concurrent users.
The data read with the datalayer is available using @Datatokens, in the format @Data.ColumnName~. The spelling of the column name is case-sensitive. The data is only available within the scope of the parent element of the datalayer, not throughout the entire report definition. The DataLayer.Linked element can be used to make the data reusable in another datalayer outside this scope.
The data retrieved into the datalayer can be viewed by turning on the Debugging Link in your _Settings definition (General element) and using the resulting link at the bottom of your report page to view the Debugger Trace page. A link on the Debug page will display the retrieved data.