What are MongoDB and G8CC.
MongoDB is a popular open source database for web apps. It's a NoSQL document-oriented database. It provides a JSON-like format with optional schemas.
GARNET8 Collaboration Clouds (G8CC) provides a powerful data sharing layer. It allows you to seamlessly integrate and extend data value. That lowers delivery and ongoing costs.
This demonstrates how to integrate and extend a MongoDB database. G8CC provides a simple solution to seamless integrate and join-up information. This empower data mobility and secure, trusted data sharing.
Throughout our data source integration series we use employees data. We continue with this theme when connecting MongoDB. We have documented how to install, securely configure and restore an employees' MongoDB database here.
In this we focus on how to connect, extend and re-purpose data. This seamlessly integrates and builds on existing data in a MongoDB database.
First you need to add a MongoDB connector to G8CC.
To do this your need:
- A MongoDB database and G8CC node running.
- The following details for your connector.
- Username and Password of the MongoDB database.
- Host name. This can be an IP address, DNS name or "localhost" if your MongoDB database is running locally.
- Port your MongoDB database is listening on. The default port for MongoDB is 27017.
- Database and collection name that we are integrating. A collection in MongoDB is like a table.
- MongoDB uses a JSON structure. This means we don't use SQL unlike in our MySQL and Postgres connectors. For MongoDB we use JSONPath syntax to extract data from our documents. These will get explained in greater details in the documentation.
Once you have these you can login to your G8CC administration interface. In the menu on the left your see a database icon. This is highlighted below with a green border (Fig 1.0). Click this to open your integrated data sources.
Fig 1.0
If you don't have any integrated data sources your have a box with a plus sign in it (Fig 1.1). You click this to add a new external data source connector. To start your configuration click the plus sign then Databases and MongoDB.
Fig 1.1
Step one.
In the first dialog box you add the connectors title and description (Fig 1.2). The title gets displayed in a number of places. These include the integrated data source list and App Wizard integrator. The title should be descriptive.
Fig 1.2
Step two.
In this step configure the connection details (Fig 1.3). This defines what to connect to and how to authenticate.
Fig 1.3
Step three.
You now defined which G8CC containers can use this integrator (Fig 1.4). This provides flexibility and allows you to govern data.
Fig 1.4
Step four.
In step four we add two JSONPaths.
Our JSONPaths populate a list of options to choose. This uses a LIKE styled expression to query MongoDB. The query is case insensitive.
These paths extract first and last name from our JSON document. The MongoDB handler in G8CC automatically selects the _id as the key. This makes it very simple. You can see in the image below (Fig 1.5) our two paths.
You can add one or more JSONPaths. The title to the left should be descriptive. This is used to match against input within our G8CC App builder. To add more JSONPaths click the "Add" button.
Fig 1.5
Step five.
G8CC will copy the JSONPaths from step four. You can add additional JSONPaths. The column names get used by the App wizard. The document key "_id" is used to select a unique from our MongoDB database. This is similar to the findOne query built into the MongoDB command line.
Fig 1.6 below shows our JSONPath. For this we will continue with first and last name.
Fig 1.6
Save connector.
These are the minimum steps needed to create a connector. We can now "Save without update query" (Fig 1.7).
Fig 1.7
You will see your new connector in the "Integrated data source" list (Fig 1.8).
Fig 1.8
Creating a G8CC view to use data in the MongoDB database.
Creating a G8CC view to use data in the MongoDB database.
To do this we open G8CC's App Wizard. The first step is to create a title and description for our app (Fig 1.9). We can then click next.
Fig 1.9
In our second step we create a view. For this we will use three input type (Fig 2.0). The first two inputs will use input (text). The third input (email) and fourth input (Telephone).
Fig 2.0
To create a view you drag the input type and drop it in the highlighted green box. An input configuration screen will appear (Fig 2.1). Each input will use the following configuration:
Fig 2.1
- Drag n' Drop Input (text) then type title "First Name". In the index section click text, then click "Save".
- Drag n' Drop Input (text) then type title "Last Name", then click "Save".
- Drag n' Drop Input (Email) then type title "Email", then click "Save".
- Lastly Drag n' Drop Input (Telephone) then type title "Number", then click "Save".
You will have created a view for your data (Fig 2.2).
Fig 2.2
You've created a view. Now click "Next".
In our final screen we can define a title and integrate our MongoDB data source. A title is similar to "Subject" in email.
In the box at the top click "#", then select "First Name", press space, then hash (#) again. Now select "Last Name" (Fig 2.3). The values in our First and Last Name inputs will replace the titles after the "@".
Fig 2.3
Next we configure our data source integrator. Click "Integrate external data source". A dialog open, click "Add". In the next dialog click "Employees Mongo". We can now match our column names to the titles of our inputs (Fig 2.4).
The table below shows the relationships.
JSONPath Query Column | View Title |
---|---|
first_name | First Name: |
last_name | Last Name: |