Skip to main content
Version: 8.1

MongoDB Bindings in Perspective

The MongoDB Cloud Connector module introduces a Perspective Binding type called MongoDB. The MongoDB binding follows the same format as the Perspective Expression Structure binding by allowing users to to bind JSON data to individual aspects of a Perspective project such as properties. In other words, building a MongoDB binding query is almost identical to building an Expression Structure binding.

Users can set polling on a MongoDB binding, updating the displayed result at set intervals.

MongoDB bindings are read-only, and will not allow any writes to your bound MongoDB collection. If you need to write to a collection or document, use the MongoDB Cloud Connector's included system functions instead.

MongoDB Binding Interface

The image and table below detail various elements of the MongoDB binding user interface.

Source and Query Type Selection

The three dropdown menus at the top of the MongoDB binding window allow you to specify where the binding's data is coming from and what you want to do with the information.

  • Connector

    • The Connector dropdown will show available configured connections to your MongoDB databases.
  • Collection

    • The Collection dropdown will display a list of available collections from the specified connection's database.
  • Query Type

    • The Query Type dropdown will offer different actions, including Find, FindOne, or Aggregate. The Query Builder will also change depending on what Query Type you select:

      • Find contains filter, project, sort, collation, limit, and skip.

      • FindOne contains filter and project.

      • Aggregate contains aggregate and collation.

Binding Options

OptionDescription
EnabledIndicates whether the binding should fire.
Overlay Opt-OutIndicates whether the component should reflect a bad quality binding via a Tag overlay.
Cache & ShareWhen this setting is enabled, the query will utilize a polling engine that is shared across all running Perspective sessions. The polling engine will run the query once, cache the value, and deliver the results to all registered consumers. The cache persists for a period of time that matches the configured poll rate. If polling is off, the default cache duration is 250 milliseconds. This optimization is helpful for consolidating multiple identical polling tasks, particularly when you have many Perspective sessions running at once. Disabling this option will bypass the cache.
PollingControls how often the binding should update.

MongoDB Expression Functions

The MongoDB Cloud Connector module also adds three new expression functions to assist in building Perspective bindings expression structure. See the MongoDB expression functions for more details.

Example

The following example pulls data from a MongoDB Atlas connection to display in a Perspective Table.

  1. Set up a MongoDB connection, if you haven't already. The steps outlined on the MongoDB User Manual page can help guide you through setting up a connection.

  2. Click on the Binding icon next to the data property.

  3. Select the MongoDB binding type.

  4. Select the Connector, Collection, and Query Type you want to use. In this example, the Connector we are using is called MongoDB Atlas TEST, the Collection we are pulling data from is called planets, and we are using a Find Query Type.

  5. You can use the Query Builder to customize your data how you want. In this example, we are pulling in all the data in the planets collection.

  6. Toggle or set any options you want, such as Polling or Cache & Share.

  7. Once you have finished building your MongoDB binding, click OK.

  8. Our Perspective Table is now populated with data from our planets collection:

note

You may need to add the column names from your target collection in order for users to be able to perform actions such as column resizing or reordering. See the column row from the Properties section of the Perspective Table User Manual page for more details.