Tag Archive for Realm

Realm Partitioning Strategies

I’ve just released a new article – Realm Partitioning Strategies.

Realm partitioning can be used to control what data is synced to each mobile device, ensuring that your app is efficient, performant and secure. This article will help you pick the right partitioning strategy for your app.

MongoDB Realm Sync stores the superset of your application data in the cloud using MongoDB Atlas. The simplest strategy is that every instance of your mobile app contains the full database, but that quickly consumes a lot of space on the users’ devices and makes the app slow to start while it syncs all of the data for the first time.
Alternative strategies include partitioning by:

  • User
  • Group/team/store
  • Chanel/room/topic
  • Geographic region
  • Bucket of time
  • Any combination of these

The article discusses all of those strategies so that you adopt one, or craft a different strategy that’s customized to your app’s needs.





New article on migrating Apple’s Scrumdinger tutorial app to Realm

Apple published a great tutorial to teach developers how to create iOS apps using Swift and SwiftUI. I particularly like it because it doesn’t make any assumptions about existing UIKit experience, making it ideal for developers new to iOS. That tutorial is built around an app named “Scrumdinger,” which is designed to facilitate daily scrum meetings. Apple’s Scrumdinger implementation saves the app data to a local file whenever the user minimizes the app, and loads it again when they open the app. It seemed an interesting exercise to modify Scrumdinger to use Realm rather than a flat file to persist the data. So. I wrote “Adapting Apple’s Scrumdinger SwiftUI Tutorial App to Use Realm” to step through what changes were required to rebase Scrumdinger onto Realm. An immediate benefit of the move is that changes are now persisted immediately, so nothing is lost if the device or app crashes. It’s beyond the scope of this article, but now that the app data is stored in Realm, it would be straightforward to add enhancements such as:
  • Search meeting minutes for a string.- Filter minutes by date or attendees.
  • Sync data so that the same user can see all of their data on multiple iOS (and optionally, Android) devices.
  • Use Realm Sync Partitions to share scrum data between team members.
  • Sync the data to MongoDB Atlas so that it can be accessed by web apps or through a GraphQL API




Accessing Realm Data on iOS using Realm Studio

The Realm Mobile Database makes it much faster to develop mobile applications. MongoDB Realm Studio is a desktop GUI that lets you view, manipulate, and import data held within your mobile app’s Realm database. I’ve just published a new article (Accessing Realm Data on iOS using Realm Studio) which steps through how to track down the locations of your iOS Realm database files, open them in Realm Studio, view the data, and make changes.




Building a Mobile Chat App Using Realm – Data Architecture

I’ve just built an iOS chat app using SwiftUI, Realm, and Realm Sync. I decided on a chat app as it makes an interesting case study for designing a data model and controlling who can access what data:

  • A chat message needs to be viewable by all members of a chat room and no one else.
  • New messages must be pushed to the chat room for all online members in real-time.
  • The app should notify a user that there are new messages even when they don’t have that chat room open.
  • Users should be able to observe the “presence” of other users (e.g., whether they’re currently logged into the app).
  • There’s no limit on how many messages users send in a chat room, and so the data structures must allow them to grow indefinitely.

Because this app’s data model (and the decisions taken when designing) serve as a great starting point for many different types of apps, I wrote it up in this HowTo article.

You can download all of the code from the GitHub repo.

Checkout Building a Mobile Chat App Using Realm – Data Architecture for all of the details.





Building an iOS app with Realm, SwiftUI, & Combine

I’m relatively new to building iOS apps (a little over a year’s experience), and so I prefer using the latest technologies that make me a more productive developer. That means my preferred app stack looks like this:
In 🔥 Out ❄️
Swift Objective C
SwiftUI UIKit
Combine RxSwift
Realm Core Data
MongoDB Realm Sync (where needed) Home-baked cross-platform data sync
I built a simple, distributed task management app on that stack, and wrote it up in “Build Your First iOS Mobile App Using Realm, SwiftUI, & Combine”. To continue my theme on being productive, I borrowed heavily from MongoDB’s official iOS Swift tutorial: You can download all of the code for the front end app from the GitHub repo. Checkout Build Your First iOS Mobile App Using Realm, SwiftUI, & Combine for all of the details.