Working with MongoDB Connections in a Catalog
A MongoDB connection contains relational schemas which are transformed from the collections in a MongoDB database. This topic describes how you can set up MongoDB connections in a catalog, and add and manage schemas and tables transformed from MongoDB databases in the catalog via the connections.
This topic contains the following sections:
- Setting Up MongoDB Connections in a Catalog
- Adding More Schemas and Tables to a MongoDB Connection
- Managing the Schemas in a MongoDB Connection
- Managing the Tables in a MongoDB Connection
Setting Up MongoDB Connections in a Catalog
To connect a catalog to a MongoDB database, you can set up a MongoDB connection as follows:
- Create a catalog or open a catalog, then in the Catalog Manager, right-click the node of a data source and select New MongoDB Connection from the shortcut menu.
If you want to set up the connection in a new data source in the catalog, select any of the existing catalog data sources, select New Data Source on the Catalog Manager toolbar, then in the New Data source dialog box, specify the name of the data source, select the MongoDB connection type and select OK.
Designer displays the MongoDB Connection Wizard dialog box.
- In the MongoDB Connection Information screen, specify the necessary information to connect to the MongoDB server.
- To connect by server host and port, select Information, then type the host and port of the MongoDB server, and the user ID and password to connect to the MongoDB server respectively.
- To connect by URI, select URI and type the URI string.
- Select Next to go to the next screen.
- If you specify to connect to the MongoDB server by host and port, Designer displays the Connection Options screen.
Select the Add button to add lines to specify the conditional replica set members for the MongoDB connection. To delete a replica set member, select it and select the Remove button .
In the Options box, specify the options of the MongoDB server. The options are name=value pairs separated by "&". You can specify the following:
- slaveOk=true|false
If true, the driver connected to a replica set sends reads to slaves/secondaries, or you can also read a slave/secondary database by adding its URI and port to the Replica Set Members box. - safe=true|false
If true, the driver sends a getLastError command after every update to ensure that the update succeed. - w=n
The driver adds { w : n } to the getLastError command. Implies safe=true. - wtimeoutMS=ms
The driver adds { wtimeout : ms } to the getLastError command. Implies safe=true. - fsync=true|false
If true, the driver adds { fsync : true } to the getLastError command. Implies safe=true. - journal=true|false
If true, sync to journal. Implies safe=true. - connectTimeoutMS=ms
How long a connection can take to be opened before timing out. - socketTimeoutMS=ms
How long a send or receive on a socket can take before timing out. - authSource=<DataBase name>
The database name associated with the credentials of the user ID if the user ID is specified in the MongoDB Connection Information screen. - ssl=true|false
If true, the SSL certificate is imported into the default JKS when you set up the connection via SSL.When you create a MongoDB connection via SSL, to make the connection work at runtime, you need to add the -Djavax.net.ssl.trustStore parameter in Server's startup file JRServer.bat in
<server_install_root>\server\bin
(the MongoDB Java driver mongo-java-driver-3.12.7.jar is already included in the Logi Report applications), so that the SSL certificate can be loaded into Server.
- slaveOk=true|false
- Select Next to go to the next screen.
- If you specify to connect to the MongoDB server by host and port and you do not have the privilege to access all the databases in the MongoDB database, Designer displays the Add Database screen. Select to add lines to specify the databases that you can access in the MongoDB database. To delete a database, select it and select .
- Select Next.
- In the Collection Filter screen, Designer lists all the available collections in the MongoDB database.
By default, Designer uses the first ten data records in each collection to parse metadata. If you want to edit the filter condition to get the required collection structure, select a collection in the Collection box, and then specify the filter in the text box by typing the part after "$match:", for example, type {author:"dave"} in the text box (for more information about the definition of $match, see https://docs.mongodb.com/manual/reference/operator/aggregation/match/#pipe._S_match). Select Apply the Filter to Run Reports if you want to apply the filter conditions to the reports which use the collections at runtime.
- In the Add Schema screen, add the collections you want to transform to relational schemas, in order to use them in the catalog.
- Select Next.
- In the Add Table screen, add the tables that Designer transforms from the specified schemas to the catalog. A table contains fields mapped to attributes, top level documents, simple elements, array elements, and other nodes in the MongoDB documents.
You can create queries and business views using these tables and a report is developed from a query (or something else which is functionally similar) or from a business view.
- Select Finish to confirm the transformed result and complete the transformation process.
Adding More Schemas and Tables to a MongoDB Connection
After you have set up a MongoDB connection in a catalog, you can add more schemas transformed from the collections in the specified MongoDB database and tables in the schemas to the catalog via the MongoDB connection.
To add more schemas to the catalog via the MongoDB connection:
- Right-click the Schemas node or an existing schema in the MongoDB connection and select Add Collection from the shortcut. Designer displays the Add Collection dialog box.
- In the Collections box, select the required collections that you want to transform to relational schemas and select the Add button to add them to the Added Schemas box.
- After adding the required schemas, select OK to close the dialog box.
To add more tables to the catalog via the MongoDB connection:
- Do one of the following:
- Right-click the MongoDB connection and select Add Tables from the shortcut menu.
- Right-click the Tables node of the MongoDB connection and select Add Tables from the shortcut menu.
- Right-click an existing table in the MongoDB connection and select Add Tables from the shortcut menu.
Designer displays the Add Table dialog box.
- In the Tables box, select the required tables transformed from the relational schemas and select to add them to the Added Tables box.
- After adding the required tables, select OK to close the dialog box.
Managing the Schemas in a MongoDB Connection
You can manage the schemas transformed from a MongoDB database via the MongoDB connection you set up in a catalog as follows:
- Refreshing the schemas
The schemas in your catalog are a temporary cache of metadata to improve performance when you design and test your report. Your database probably changes over the time; however, these changes cannot be reflected automatically in your catalog. To refresh all of the collection schema metadata from the MongoDB database, you can refresh the schema information using the Refresh command on the shortcut menu of the schema. When Designer finishes the refreshing job, it displays a reporting dialog box, summarizing the changes and operations that have been taken.If you want to add all the deleted or missing databases at one time, you can also refresh the schema, which refreshes all of the collection schema metadata from the MongoDB database.
- Renaming databases of the schemas
Right-click the database and select Rename from the shortcut menu, and then type the required database name in the text box.- If the renamed database exists in the MongoDB database, it connects to the new database.
- If the renamed database does not exist in the MongoDB database, no data is retrieved.
- Removing databases of the schemas
Right-click the database and select Delete from the shortcut menu.
Managing the Tables in a MongoDB Connection
For the tables that have been transformed from a MongoDB database and added into a catalog via a MongoDB connection, you can refresh them, organize them into folders, and remove and add the table columns the same as you do with tables from a JDBC database.