Creating MongoDB Object Service
Creating a MongoDB Object Service
With Object Services, you can create an object on VoltMX Foundry that uses MongoDB for storing data for apps.
MongoDB is a free and open-source cross-platform document-oriented database. Classified as a NoSQL database, MongoDB avoids the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster.
How to Create a MongoDB Object Service
To create a MongoDB object service, do the following:
-
On the Apps page, click Add New.
-
Click the Edit App Name button to enter a unique name for the app. For example, SampleMongoDBApp.
-
Click the Objects service tab.
-
Click Configure New.
-
Click in the Name field, and enter a name for the object service. For example, SampleMongoDBObject.
-
Click in the Endpoint Type field. In the drop-down menu, select MongoDB.
-
Under Security Level, select Authenticated App Use. If you set the security level to Public, you are not required to enter the user name and password.
-
Click in the Hostname field. Enter the name of the MongoDB host.
-
Click in the Port field. Enter the port of the MongoDB.
-
Click in the Database Name field. Enter the name of the MongoDB database that you are using for the object service.
-
If you have set up an identity service that validates the authentication of the users before accessing your application, enter the user name and password for the Identity Service.
-
Optionally, enter the following properties for the MongoDB database: Connections per host (the total number of connections available for connection to the host), Maximum wait time (wait time in microseconds for the lock acquisitions), Connection timeout (the default is never timeout), Socket timeout (the default is never timeout), and Description.
-
Click Save & Configure.
- On the Configure page for the object service, click Generate.
-
On the Import Objects from Backend screen, select MongoCollection and MongoDocument, and then click Next.
-
Click Generate.
Test the Methods in the Data Model
-
Click the Mapping tab in the navigation pane.
-
Expand the MongoCollection object.
-
Click Create.
-
Click the Test tab.
-
In Request Payload, enter the name of a collection to create. For example, myTestCollection.
-
Expand the MongoDocument object.
- Click Create.
- In the Mapping Configuration screen, click Test.
- In Request Payload, type the following code to add a record to the collection.
- Click Send.