Skip to main content
Version: 8.1

MongoDB

MongoDB is a non-relational, NoSQL database. Unlike relational SQL databases like Microsoft SQL Server, MongoDB uses a JSON-like structure called collections instead of tables, with each JSON "row" referred to as a document. This in turn leads to lighter queries, helping optimize the performance of your Gateway and database connection.

Aside from a local installation, MongoDB can also be hosted in the cloud using the cloud service MongoDB Atlas. There are specific features which may draw users toward MongoDB Atlas, such as not needing to maintain a server or configure any clusters.

See the official MongoDB documentation for more information on MongoDB and MongoDB Atlas.

Module Information​

The MongoDB Cloud Connector module comes with Ignition Cloud Edition, but can also be used with a standard version of Ignition. Features of the MongoDB Cloud Connector include:

Gateway Interface​

After installing the MongoDB Cloud Connector, there will be new options available on the Gateway webpage's Status and Config pages.

Status Page​

The Gateway webpage's Status page will show information about your MongoDB connections. See the Connections - MongoDB page for more information.

Config Page​

The Gateway webpage's Config page will allow you to make connections from Ignition to MongoDB databases. To set up a MongoDB connection, navigate to the Gateway webpage's Config section > Connectors > MongoDB.

Config Page MongoDB

The table below outlines the properties available when creating or editing a MongoDB connection:

PropertyDescription
NameThe name of your MongoDB connection.
DescriptionA description of your MongoDB connection.
Connection SchemePrefix that identifies the connection format. Default is mongodb.
Note: If you are creating a connection to MongoDB Atlas, you will need to change the Connection Scheme to mongodb+srv.
Connection HostsHost or list of hosts to connect to, comma separated. If no port is specified, the default port of 27017 is used.
DatabaseThe name of the database to connect to.
UsernameThe username to use when connecting.
Change Password?Check this box to change the existing password. This property will not be available for new connections.
PasswordThe password to use when connecting.
PasswordRe-type password for verification.
Connection PropertiesAny extra connection properties you need to specify, such as enabling or disabling TLS.
  • If you are using mongodb+srv as the Connection Scheme to connect to MongoDB Atlas, TLS will be enabled by default.
  • If you are using mongodb as the Connection Scheme to connect to MongoDB, TLS will be disabled by default.
Note: If you are using a trusted certificate, Ignition will automatically use the certificate without needing any configuration. If you are using a custom or self-signed certificate, you will need to specify the location of the certificate, as well as any other identifying information such as the password.
EnabledEnable or disable the database connection. Default is true.

Connecting to MongoDB​

With the MongoDB Cloud Connector installed, you will be able to connect to a MongoDB database. The steps below outline how to connect to MongoDB. In this example, we will be connecting to MongoDB Atlas.

Get the Connection URL​

  1. Go to your MongoDB Atlas Dashboard and click Database in the Deployment section.

    Get the Connection URL Step 1

  2. On the Database Deployments window, click Connect.

    Get the Connection URL Step 2

  3. You will be prompted to choose a connection method. Click Connect your application.

    Get the Connection URL Step 3

  4. Choose Java for the driver, and select the latest version. Your connection URL will appear, giving you the information you need to connect Ignition to your MongoDB database.

    Get the Connection URL Step 4

Interpreting the Connection URL​

The connection URL will have all the information necessary to set up a basic connection. Note that you will still need to specify extra connection properties such as Transport Layer Security (TLS) or certificates should you need them.

Your connection URL will look something like the example below, with specific sections of the connection URL corresponding with specific Gateway fields from the MongoDB connection setup process.

mongodb+srv://<username>:<password>@<clustername.example.mongodb.net>/?retryWrites=true&w=majority
Gateway FieldConnection URL Value
Connection Schememongodb+srv (or mongodb if not using MongoDB Atlas)
Connection Hosts<clustername.example.mongodb.net>
Username<username>
Password<password>
Connection PropertiesretryWrites=true&w=majority (You can also add extra connection properties here)

Get the Database Name​

  1. On the MongoDB Atlas Dashboard, navigate to Deployment > Database > Your Cluster Name > Browse Collections.

    Get the Database Name Step 1

  2. Your dashboard will list any existing databases within your cluster. Choose which database to connect to from this list. In this example, we will be using the sample_guides database.

    Get the Database Name Step 2

Connect Ignition to MongoDB​

  1. Navigate to Config > Connectors > MongoDB on the Gateway, and click Create new MongoDB Connector.

    Connect Ignition to MongoDB Step 1

  2. Fill out the Gateway fields with the appropriate information from your connection URL and the database name, then click Create New MongoDB Connector.

    Connect Ignition to MongoDB Step 2

  3. Your MongoDB connection is now created. It may take a few seconds for your connection to update to a "Valid" status.

MongoDB Perspective Bindings​

Users can pull data from a MongoDB database to populate Perspective components. MongoDB Perspective bindings are read-only, so users will not be able to write to collections from the binding itself. See the MongoDB Bindings in Perspective page for more details.

MongoDB System Functions​

While the MongoDB Perspective binding itself has no write capabilities, the included MongoDB System Functions allow users to read, update, delete, and take aggregates of collection documents. See the MongoDB System Function page for a list of available system functions.