MongoDB Binders

Introduction

The MongoDB Binders plugin facilitates the seamless integration of MongoDB and Joget. This integration currently utilises few plugin types:

  • Data List Filter: To filter the dataset to refine the result. Includes types for: Date, Date Range, Number, Options, Text Field.
  • Datalist Binder: To populate datalist with data retrieve from the MongoDB database.
  • Form Load Binder: To retrieve form data from the MongoDB database.
  • Form Store Binder: To store form data in the MongoDB database.
  • Form Options Binder: To populate the options field with data retrieve from the MongoDB database.
What is MongoDB?
MongoDB is an object-oriented, simple, dynamic, and scalable NoSQL database. It is based on the NoSQL document store model.
The data objects are stored as separate documents inside a collection instead of storing the data in the columns and rows of a traditional relational database.
With these integration plugins, you can store and load data from form, datalist, and grid.

Plugin information

Plugins Available in the Bundle:

  1. MongoDB Data List Filter
  2. MongoDB Datalist Binder
  3. MongoDB Form Load Binder
  4. MongoDB Form Store Binder
  5. MongoDB Form Options Binder

This plugin bundle is compatible with Joget DX 8.

Getting started

Prerequisites

You must have MongoDB Community Edition installed on your machine or server.

Where to get the plugin

You can download the MongoDB Binders plugin from the Joget Marketplace.

How to install

  1. Click Download on this plugin screen (It will be a .jar file).
  2. Go to your Joget localhost or server. In the Joget Console, go to Admin Bar > Systems Settings > Manage Plugins and click the Upload Plugins button.
  3. Under Upload Plugin, select the plugin .jar file you downloaded and click Upload.
  4. Depending on the plugin type, you can now view your new plugin in your form, List, or UI Builder.
  5. Remember to uninstall the old plugin before uploading a new version.
  6. The Joget Knowledge Base has more information on managing and developing plugins.

Setting up MongoDB

1. Install MongoDB Community Edition

Install MongoDB Community Edition on Linux/MacOS/Windows or with docker. See Install MongoDB Community Edition - MongoDB Manual v7.0.

2. Start MongoDB Community Edition

Start and access MongoDB from your shell

mongosh

See Welcome to MongoDB Shell (mongosh) - MongoDB Shell

3. Create MongoDB Database

After connecting to the shell, create a new database.

use jwdbtest

See MongoDB mongosh Create Database (w3schools.com)

4. Create MongoDB Collection

Create a new collection under the database.

db.createCollection("posts")

See MongoDB mongosh Create Collection (w3schools.com)

5. Use Database Management Tool (optional)

You can use any database management tool (Eg, tableplus, dbeaver...) and check if the database and collection is created.

Configuration steps

Import MongoDB Binders plugin into Joget App

  1. You can obtain the jar file by the latest release at https://github.com/jogetoss/mongodb-binder/releases.
  2. Upload the plugin jar file in Joget by going to Settings → Manage Plugins.

Create new Joget app

  1. Create a new form and add some fields into the form.
  2. On the Settings tab, select MongoDB Form Load Binder for Form Load and MongoDB Form Store Binder for Form Store.
  3. Click next, fill in the database name created in Step 3 and the collection name created in Step 4, the Setting up MongoDB section. For more plugin configurations, see Configure MongoDB Form Load Binder and Configure MongoDB Form Store Binder.
  4. Save the form.
  5. Drag a select box into the form. You can load data from the MongoDB Form Options Binder. For plugin configurations, see Configure MongoDB Options Binder.
  6.  Save the form again.
  7. On the upper right corner, click on Generate App > Generate CRUD.
  8. Go to the list generated and change the Select Source of Data to MongoDB Datalist Binder. For plugin configurations, see Configure MongoDB Datalist Binder.
  9. Go to the Design tab, drag some fields into the filter area, and under Type, you can see the MongoDB Data List Filters by different types. For plugin configurations, see Configure MongoDB Datalist Filter.
  10. Now run the UI. Add a new record and fill in the values. Click save.
  11. You can now see the value in the MongoDB database. You can also see the value in datalist where we configured the datalist binder.
  12. Click on edit record. You can now see the record under the select box where you configured the form options binder.

MongoDB binders properties

Configure MongoDB datalist filter

Fields to configure:

Configure MongoDB datalist binder

Fields to configure:

  • Host: Target host to connect to MongoDB instance
    Choices:
    • Local MongoDB Instance: Leave the Host field blank (Link to default localhost).
    • MongoDB Instance on a Remote Host:Example: "mongodb0.example.com:28015".
  • Port: Connect to a MongoDB instance running on your localhost or remote host.
     Choices:
    • Default Port: Leave the Port field blank (Link to default port: 27017).
    • Non-default port: To connect to a MongoDB instance running on localhost with a non-default port. Fill 28015(non-default port) in the port field.
  • Username: Enter the username if authentication is required; otherwise, leave it blank.
  • Password: Enter the password if authentication is required; otherwise, leave it blank.
  • Database Name: The name of the database in MongoDB, which holds collections of documents. This field is mandatory for plugin access.
    Test the connection parameters
    Click the Test Connection button at the bottom of the page to quickly test your configurations.
  • Collection Name: Enter the target collection name to load data. This field is mandatory.
 

Configure MongoDB form load binder

Fields to configure:

  • Host: Target host to connect to MongoDB instance.
    Choices:
    • Local MongoDB Instance: Leave the Host field blank (Link to default localhost)
    • MongoDB Instance on a Remote Host: Example: "mongodb0.example.com:28015".
  • Port: Connect to a MongoDB instance running on your localhost or remote host.
    Choices:
    • Default Port: Leave the Port field blank (Link todefault port: 27017).
    • Non-default Port: To connect to a MongoDB instance running on localhost with a non-default port. Fill 28015(non-default port) in the port field.
  • Username: Enter the username if authentication is required; otherwise, leave it blank.
  • Password: Enter the password if authentication is required; otherwise, leave it blank.
  • Database Name: The name of the database in MongoDB, which holds collections of documents. This field is mandatory for plugin access.
    Test the connection parameters
    Click the Test Connection button at the bottom of the page to quickly test your configurations.
  • Collection Name: Enter the target collection name to store or load data. This field is mandatory.
  • Primary Key Field: Enter the primary key field to identify rows of data. This field is used to load data based on primary key values.
  • Used for Grid?: If checked, the binder will be used for Grid.
    Important:
    Remember to configure the Foreign Key Field in the Used for Grid so that the data will load into the grid based on the foreign key. This field is mandatory.

     When the Used for Grid option is checked.

Configure MongoDB form store binder

Fields to configure:

  • Host: Target host to connect to MongoDB instance.
    Choices:
    • Local MongoDB Instance: Leave the Host field blank (Link to default localhost)
    • MongoDB Instance on a Remote Host: Example: "mongodb0.example.com:28015".
  • Port: Connect to a MongoDB instance running on your localhost or remote host.
    Choices:
    • Default Port: Leave the Port field blank (Link todefault port: 27017).
    • Non-default Port: To connect to a MongoDB instance running on localhost with a non-default port. Fill 28015(non-default port) in the port field.
  • Username: Enter the username if authentication is required; otherwise, leave it blank.
  • Password: Enter the password if authentication is required; otherwise, leave it blank.
  • Database Name: The name of the database in MongoDB, which holds collections of documents. This field is mandatory for plugin access.
    Test the connection parameters
    Click the Test Connection button at the bottom of the page to quickly test your configurations.
  • Collection Name: Enter the target collection name to store or load data. This field is mandatory.
  • Used for Grid?: If checked, the binder will be used for Grid.
    Important:
    Remember to configure the Foreign Key Field in the Used for Grid so that the data will load into the grid based on the foreign key. This field is mandatory.
 

Configure MongoDB options binder

Fields to configure:

  • Host: Target host to connect to MongoDB instance.
    Choices:
    • Local MongoDB Instance: Leave the Host field blank (Link to default localhost)
    • MongoDB Instance on a Remote Host: Example: "mongodb0.example.com:28015".
  • Port: Connect to a MongoDB instance running on your localhost or remote host.
    Choices:
    • Default Port: Leave the Port field blank (Link todefault port: 27017).
    • Non-default Port: To connect to a MongoDB instance running on localhost with a non-default port. Fill 28015(non-default port) in the port field.
  • Username: Enter the username if authentication is required; otherwise, leave it blank.
  • Password: Enter the password if authentication is required; otherwise, leave it blank.
  • Database Name: The name of the database in MongoDB, which holds collections of documents. This field is mandatory for plugin access.
    Test the connection parameters
    Click the Test Connection button at the bottom of the page to quickly test your configurations.
  • Collection Name: Enter the target collection name to store or load data. This field is mandatory.
  • Use AJAX for cascade options?: When checked, this allows these fields to dynamically load available options based on the other field value (grouping column) when dealing with tremendous amount of selections. For more information, see Dynamic Cascade Drop-downs.
    Important
    Remember to configure the dependency field in Field ID to control available option based on Grouping in the next tab.

    Fill in the Grouping Field in the MongoDB Option Binder Properties to represent dependency values.
  • Add Empty Option: Click this checkbox if you want an empty option in the select box.  Clicking this option will display the following field:
    • Empty Option Label - Enter your empty label. For example, Select.
  • Value, Label, and Grouping Field: 

    To populate a select box, for example, you need to return at least 2 objects.

    • The first object is used for Id(Value Field).
    • The second object is used for Label(Label Field).

    An optional third column(Grouping Field) can be returned for grouping value if, for example, you are using the select box Field ID to control available options based on Grouping property field.

    When Use AJAX for cascade options is checked, ensure the Grouping Field is filled.

  • Filter Condition: The filter can be used to filter load options data.

Expected outcome

Upon successful integration, Joget will be able to connect to MongoDB to store and retrieve data.

Download plugin

Created by Julieth Last modified by Aadrian on Nov 19, 2024