• Post author:
  • Post category:MongoDB
  • Post last modified:May 9, 2024
  • Reading time:9 mins read
You are currently viewing MongoDB Realm

MongoDB Realm is a cloud-based mobile application development platform that allows developers to build and deploy modern mobile applications easily. It offers a serverless backend so that programmers can concentrate on creating wonderful user experiences without bothering about infrastructure administration.

Advertisements

1. Create a new MongoDB Realm project

Firstly, the prerequisite to creating the MongoDB Realm project is that we should have the MongoDB atlas account. After that, we must sign in with and create a new cluster and choose a region, cluster tier, and storage capacity.  Here, create a new project by specifying the name of the project as in the following image.

Realm in MongoDB

After creating the project, we must construct the database in the “Data Services” section. Next to the Data Services, we have “App Services” on the atlas page as shown below to create the realm application.

Realm in MongoDB

2. Create a new Realm Application

On the App services section, we can see two options for creating the application of MongoDB Realm. We must choose either the Create App From Template option or the Create a New App option to build the application from scratch.

Here, we choose the Create App From Template option, which opens the following dialogue box. The Name field’s option must be filled out with the application’s name. After that, we must link with the database, or else the application will not be generated. We may explore the specified option according to our requirements. 

Realm in MongoDB

Finally, the application of Realm is created. Now, we can define many features of MongoDB Realm by exploring the given option. Note that for every application we create in the MongoDB realm, we have a unique App ID that helps us access it. 

A button labeled pull front-end code is present, as can be observed in the image above. From here, we can get the front-end code of our realm application in our system by clicking on it. The following pop-up will be raised which gives us the option to download the application.

Realm in MongoDB

However, we can also define the schema of our application from the Data Access option placed at the left sidebar of the page. There, we can define the custom schema, but the sample template is also the option we selected for our application below.

3. Deployment of the MongoDB Realm Application

Now, we are on the Deployment page of our application, which is listed in the Manage option of the left sidebar section. There, we can deploy our application by viewing the history, managing the configuration, exporting the application, and, more important, setting the environment of the realm application. Below, we attempted to export the data via MongoDB realm-cli.

Realm in MongoDB

All we need to do is, open the command prompt and install the mongodb-realm-cli by using the following command.


# install mongodb-realm-cli
npm install -g mongodb-realm-cli

We get the mongodb-realm-cli here. Now, we can access the deployed application using the URL provided by MongoDB Realm.

Lastly, we pulled our application created above by connecting with the APP ID generated by the MongoDB Realm. Following is the command pulled from our application.


# pull application by connecting with the APP ID
realm-cli pull –remote myapp-sobc

On the execution of the command, there are various projects listed in the output. We can select the one where our application is placed using the move keys.

Realm in MongoDB

Hence, the application is successfully downloaded within our system. This is just a simple example, but we can build more complex apps using MongoDB Realm by adding more functionality and integrating other services.

Realm in MongoDB

4.  Conclusion

In conclusion, we can now manage the infrastructure because of MongoDB Realm, which allows us to concentrate on developing fantastic user experiences. MongoDB Realm is a serverless application development platform offered by MongoDB. It provides a set of services and tools that allow you to build and deploy applications quickly and easily, particularly for mobile and web applications.

From here, we can continue to build and expand our application using MongoDB Realm features and functionality.

More details on this topic can be found here.