Watch keynotes and sessions from MongoDB.live, our virtual developer conference.

Live chat or similar type of application using Realm

Hi
I built a mobile app using mongodb stitch and atlas and it was great. I used mongodb authentication email/password, used stitch functions as well as connecting with AWS services (ses in this case)
However, I needed to add a live chat feature and at that point I had to use an third party service to manage that. I was wondering if with realm, there is a possibility to build live type of functionality (mainly be able to listen to the server for any data change)

@ismael You certainly could implement a chat like feature using realm but it really depends on your use case because realm sync uses partitions to synchronize data between users - https://docs.mongodb.com/realm/sync/partitioning/

So if the chat rooms are limited and can be statically defined then you can share realms(partitions) between users which would replicate chat messages. For instance, an application where users are grouped into shared branch locations, and at those small branch locations users can chat with each other, individually or in groups.

The issue that can arise is if you need more complicated permissions within the branch or within chatrooms - the partitioning model is read or read/write per realm/partition per-user.

A chat application is pretty complicated in and of itself to implement which is why there are so many 3rd party providers that just do chat as a service.

1 Like

Thanks Ian
Is it not possible to define realm partitions on the fly?

@ismael It is possible to define partitions on the fly, yes