Hello everybody me Saurabh :D

A few week’s ago, I watched the MongoDB Live 2020. An event MongoDB organizes every year about their updates, keynotes, more… So, that was cool, I enjoyed the developer chat, sessions, and keynotes. The MongoDB devs are pushing forward to make MongoDB the best database platform in all. (like it)

This year they announced many wanted updates, and to be honest there are dozens of cool things coming to MongoDB platform 👍. The two new products that are released by the MongoDB Platform are the MongoDB Realm and MongoDB Charts. I don’t want to cover everything that has been released by MongoDB but a straight focus on MongoDB Realm. (most interested in this 😁)

What is MongoDB Realm ?! (some features are in BETA though)

Simply: MongoDB Realm is a serverless platform for building apps on any platform (mobiles, web, servers). It is a collection of features to build your App faster ( like Firebase ). it has a set of tools, libraries, and SDKs for all platforms to play with. In this blog, I will focus on the Web Platform, although there are three — Mobile Platform, Web Platform, and Backend Platform supporting different languages. For more info. check out their docs.

Let’s see what’s inside 📖

Exciting for what Realm provides for Web Developers (it is also for backend Application and Mobiles, but in this blog, we will focus on the only Web! because that will be too.. much!), it features, to be honest for Web Developers it seems very promising. We will start by talking about what services Realm provides and talking a bit about them.

1) Authentication

Authentication and Authorization is well the most important aspect of every modern App. Let’s see how Realm does this. Realm provides different Authentication providers. See image -

As well you can add custom data for the user, and see all users.

We all know that if we write a complete Authentication Backend with NodeJS and MongoDB Atlas how much time can take, let’s see how we can do this directly in our Realm Serverless App.

SignUp: await app.auth.emailPassword.registerUser(email, password); Boom!


const credentials = Realm.Credentials.emailPassword(email, password);

const user = await app.logIn(credentials);

LogOut: await app.currentUser.logOut();

The app is another line of code that will define your realm app:

import * as RealmWeb from "realm-web"; lib link

const app = new RealmWeb.App({ id: "<Your App ID>" });

Account Email Confirmation: await app.auth.emailPassword.confirmUser(token, tokenId); ****

Password Reset Email: await app.auth.emailPassword.sendResetPasswordEmail(email);

Password Reset: await app.auth.emailPassword.resetPassword(token, tokenId, "newPassw0rd");

:o Ya, it’s that easy! Surprising ya! Spoiler Alert: There are more amazing things. 😁

2) Database

It is the most interesting part.

If you already know MongoDB and Mongoose you will become very familiar with it. You just simply make a Schema from the Realm UI of an existing database in Atlas.

Ya, the Schema writing is a little different but very understandable and easy. 😋

You can also make Relationships (Relationships define connections from documents in this collection to documents in another collection) and

defined Filters (Filters are applied to entire documents when a specified condition is met. A filter query is appended to the end of a request to MongoDB so that fewer documents return and have better application performance.) to that collection.

Also, you can make typically embedded or relational document, the Whole Atlas world also in the Realm ($maybe$ xD)

So, now how I can access my database ?? You are done, you have done! Seriously.

What you were doing here is you made a GraphQL Server, Yes!!

You can test here all your Queries and Mutations of your Database created by Realm, also they are documented ( in Right-hand Side ).

This is their docs so how to do it in an App with Apollo Client.

3) Authorization

For users to access or not access the specific data you can also set rules for your database.

4) Functions

Realms Functions are just functions that you can execute anytime in your App or UI, as you can see in the image, you can pass the arguments, call them, and see results, done! I mean, cloud functions are very helpful in some situations. You can also set who can run this function, How this function will run!

Aaaand!! Spoiler Alert! You can also import your favorite Node libraries to do something amazing in these functions!

5) Triggers

Did u understand with the name?? It’s easy, in short, We can trigger some Functions (above ^ OR Amazon Event Bridge Function) on an event.

The Event that causes the function to execute can be anything, Create/Update/Delete in a collection or when Auth State Change (user SignUP, login, or SignOut).

You can also make Schedule events, that will execute on time that you provide. Schedule events can be easy or very complex using CRON.

6) 3rd Party Services

Wanna more!!

You can also add 3rd party services to work with. Example: Something happened in your Github Repo and want to update your database automatically! This will be helpful! xD

7) Values & Secrets

Realm also provides you to store some variables and important Secrets. ( Safe Backennnnnd! )

8) Hosting

One more good feature of the Realm is that it also gives you the power to host your Realm frontend app using build code. :D

Oof… That was big .. xD

I am so excited about MongoDB Realm. Do u? The beta is already a beast, let’s see when 1.0 comes on to make our real-world apps powered to Realm. For MongoDB developers, it’s a fun of both Worlds. :D If you are excited too and wanna make apps, you can try but I will not recommend making real apps right now because Realm is currently in beta, things may change and code can break many times.

That’s was it for this blog, if you want to up-to-date in this fast pace technology time, you can follow me on twitter and get updates when I post another blog, for now…


Full Stack Developer & Designer