SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Downloaden Sie, um offline zu lesen
Realm - The Secret Sauce for
Better Mobile Apps
Ankit Kakkar, Technical Services, MongoDB
Expectations for Mobile Apps are high
What is Realm?
1. Native on-device object database
2. Cloud service that allows seamless synchronization and sharing
across devices
The failed promise of ubiquitous connectivity
• Even in major cities connectivity is spotty
• Go to the countryside, still many places with no connectivity
• Crises or huge events often takes down connectivity
• Developing countries are the next big market, but there
connectivity is even worse, and bandwidth is expensive
How do you deal with this reality as a developer?
Developer experience is key
• A data model that fits seamlessly with the platform and
programming language
• Transparent synchronization that just works
• A conflict resolution model that works both in realtime, and when
users are offline for extended periods of time
Realm is a mobile database
Cross-platform
Operating Systems
Languages/Platforms
Realm’s open-source on-device
database:
• Usage: 100k+ developers; 65% of
Fortune 1000; 2B+ app installs
• 50k+ Github stars
• 18k+ Twitter followers
• Active community involvement
Traditional App Development
Leverage Sync:
MobileServer
Realtime data sync
Create a persistent shared state
Realm Mobile Database
• Offline-first API
• Object interface with native support for
relationships
• Change notifications keep UI up-to-date
• Abstracts network handling
• Removes (de)serialization
• Built-in encryption
Realm Sync Server
• Realtime sync
• Automatic conflict resolution
• Flexible schema change support
• Event handling
• Integrate existing infrastructure
• Supports data push
Realm Sync characteristics
• Write to (synced) DB = implicit syncing
No sync specific code to write.
• Persistent Connection (web socket)
• Deterministic & Strong Eventually consistent conflict resolution
• Native event handling & data push.
• Efficient data exchange
- Only diff (field level)
- Compressed Binary format
• Two modalities:
- Sync full shared data-set (full sync)
- Subscribe to sub-set (Query-based sync)
Realm is an object database
An Object Database
• Represents an instance of a Realm
database container (can be a file, or in
memory)
• Data internally represented and exposed as
objects
• Relations are linked lists / pointers
• Cross platform
• ACID compliant, performant
Native objects map directly to the database
public class Dog extends RealmObject {
private String name;
private int age;
// ... Generated getters and setters ...
}
public class Person extends RealmObject {
@PrimaryKey
private long id;
private String name;
private RealmList<Dog> dogs; // Declare one-to-many relationships
// ... Generated getters and setters ...
}
Relationships
// persons => [U1,U2]
RealmResults<Person> persons = realm.where(Person.class) .equalTo("dogs.color", "Brown")
.findAll();
Query across the object graph
// Query using a predicate string
let johnsDogs = realm.objects(Dog.self).filter(”owner.name = 'John'")
// Query using an NSPredicate
let predicate = NSPredicate(format: "color = %@ AND name BEGINSWITH %@", "tan", "B")
let tanDogs = realm.objects(Dog.self).filter(predicate)
// Sort tan dogs with names starting with "B" by name
let sortedDogs = realm.objects(Dog.self).filter("color = 'tan' AND name BEGINSWITH 'B'”)
.sorted(byKeyPath:"name")
Easy and safe multi-threading with
transactions
// create new object
let person = Person(name: "Jane")
// add to realm in transaction
try! realm.write {
realm.add(person)
}
Realm objects has a special capability…
Objects and queries live-update in response
to changes
// Query Realm for all dogs less than 2 years old
let puppies = realm.objects(Dog.self).filter("age < 2")
puppies.count // => 0 because no dogs have been added to the Realm yet
// Persist your data easily
try! realm.write {
let myDog = Dog(name: “Fido”, age: 1)
realm.add(myDog)
}
// Queries are updated in realtime
puppies.count // => 1
Realm is a live object database
Bind directly to components for reactive UI
// Observe Results Notifications
notificationToken = results.observe { [weak self] (changes: RealmCollectionChange) in
guard let tableView = self?.tableView else { return }
switch changes {
case .initial:
tableView.reloadData()
case .update(_, let deletions, let insertions, let modifications):
// Query results have changed, so apply them to the UITableView
tableView.beginUpdates()
tableView.insertRows(at: insertions.map({ IndexPath(row: $0, section: 0) }), with: .automatic)
tableView.deleteRows(at: deletions.map({ IndexPath(row: $0, section: 0)}), with: .automatic)
tableView.reloadRows(at: modifications.map({ IndexPath(row: $0, section: 0) }), with: .automatic)
tableView.endUpdates()
case .error(let error):
}
Backend integration
§ Event handling
§ Listen and respond to changes from clients
§ Pass along data to other systems or databases
§ Connectors to 3rd party databases
§ Two-way sync to legacy databases
§ Postgres and SQL Server. MongoDB coming!
§ Integrations (via Node.js & .NET SDK)
§ Identical object interface
§ Full database capabilities
§ Apply changes to push data
§ Mobilize legacy APIs
§ An easier way to integrate legacy data with mobile devices
§ Keep complexity in backend
Make a synced Realm with one line change
• Instead of a file path, specify a URL pointing to the realm in the cloud.
• Exactly the same as a local realm, but now with background synchronization.
// Create the configuration
SyncUser user = SyncUser.currentUser();
String url = "realms://myinstance.cloud.realm.io/~/userRealm";
SyncConfiguration config = user.createConfiguration(url).build();
// Open the remote Realm
Realm realm = Realm.getInstance(config);
// Any changes made to this Realm will be synced across all devices
Realm + MongoDB
Realm Mobile
(Database & Sync)
QueryAnywhere Functions
MongoDB Realm (“Stitch”)
Realm Sync
MongoDB Atlas
Rules
Digital Transformation Use Case
Food Services Companies
• Real-time Inventory updates at meal purchase
• Reliable (offline) inventory reconciliation (think
“walk-in” fridge)
• Synchronize supply catalog & meal planning
• Automated order submit
Result: Highly Automated Process Flow
Digital Transformation Use Case
Flight Management / Reporting
Pilot & Crew focused:
• Crew management:
• Scheduling
• Check-in/out
• Flight tracking
• Fuel, Speed
• Event Logging, Incident tracking
Result: Replacing lots of paperwork!
Digital Transformation Use Case
Major Cruise Vacation Company
• Food/Drink orders management:
• Order capture, Bar workflow,
• Fulfillment tracking (Billing)
• Excursion Pre-booking
• Each On-Island ‘Activity’ has their dedicated device with
synced booking info
• Check-in, up-sells synced locally,
• Fulfillment tracking (for Billing)
Result: automated & simplified communication
“Ship-to-shore”
Digital Transformation Use Case
National Police Force (Europe)
Realtime empowered Police Force
• Enable Chat & Messaging amongst force
members
• Evidence and Note capture (shared)
• Task sharing, team assignment
• Everything realm-time & offline
Results: (under development)
Thank You!
MongoDB .local Bengaluru 2019: Realm: The Secret Sauce for Better Mobile Apps

Weitere ähnliche Inhalte

Was ist angesagt?

Mongo db eveningschemadesign
Mongo db eveningschemadesignMongo db eveningschemadesign
Mongo db eveningschemadesign
MongoDB APAC
 

Was ist angesagt? (20)

AWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas TutorialAWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas Tutorial
 
Serverless Reality
Serverless RealityServerless Reality
Serverless Reality
 
Solving your Backup Needs - Ben Cefalo mdbe18
Solving your Backup Needs - Ben Cefalo mdbe18Solving your Backup Needs - Ben Cefalo mdbe18
Solving your Backup Needs - Ben Cefalo mdbe18
 
Azure Labs: Confluent on Azure Container Services & Real-time Search with Red...
Azure Labs: Confluent on Azure Container Services & Real-time Search with Red...Azure Labs: Confluent on Azure Container Services & Real-time Search with Red...
Azure Labs: Confluent on Azure Container Services & Real-time Search with Red...
 
10 - MongoDB
10 - MongoDB10 - MongoDB
10 - MongoDB
 
MongoDB World 2019: Distributed Transactions: With Great Power Comes Great Re...
MongoDB World 2019: Distributed Transactions: With Great Power Comes Great Re...MongoDB World 2019: Distributed Transactions: With Great Power Comes Great Re...
MongoDB World 2019: Distributed Transactions: With Great Power Comes Great Re...
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas JumpstartMongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
 
MongoDB at Baidu
MongoDB at BaiduMongoDB at Baidu
MongoDB at Baidu
 
How Thermo Fisher is Reducing Data Analysis Times from Days to Minutes with M...
How Thermo Fisher is Reducing Data Analysis Times from Days to Minutes with M...How Thermo Fisher is Reducing Data Analysis Times from Days to Minutes with M...
How Thermo Fisher is Reducing Data Analysis Times from Days to Minutes with M...
 
Rpsonmongodb
RpsonmongodbRpsonmongodb
Rpsonmongodb
 
What's new in MongoDB 2.6
What's new in MongoDB 2.6What's new in MongoDB 2.6
What's new in MongoDB 2.6
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep DiveMongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
 
Cassandra 2.0 (Introduction)
Cassandra 2.0 (Introduction)Cassandra 2.0 (Introduction)
Cassandra 2.0 (Introduction)
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
 
New Features in MongoDB Atlas
New Features in MongoDB AtlasNew Features in MongoDB Atlas
New Features in MongoDB Atlas
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 MongoDB SoCal 2020: MongoDB Atlas Jump Start MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB SoCal 2020: MongoDB Atlas Jump Start
 
Mongo db eveningschemadesign
Mongo db eveningschemadesignMongo db eveningschemadesign
Mongo db eveningschemadesign
 
Streaming ETL for Data Lakes using Amazon Kinesis Firehose - May 2017 AWS Onl...
Streaming ETL for Data Lakes using Amazon Kinesis Firehose - May 2017 AWS Onl...Streaming ETL for Data Lakes using Amazon Kinesis Firehose - May 2017 AWS Onl...
Streaming ETL for Data Lakes using Amazon Kinesis Firehose - May 2017 AWS Onl...
 
What's new in MongoDB 2.6 at India event by company
What's new in MongoDB 2.6 at India event by companyWhat's new in MongoDB 2.6 at India event by company
What's new in MongoDB 2.6 at India event by company
 
Real-Time Log Analytics using Amazon Kinesis and Amazon Elasticsearch Service...
Real-Time Log Analytics using Amazon Kinesis and Amazon Elasticsearch Service...Real-Time Log Analytics using Amazon Kinesis and Amazon Elasticsearch Service...
Real-Time Log Analytics using Amazon Kinesis and Amazon Elasticsearch Service...
 

Ähnlich wie MongoDB .local Bengaluru 2019: Realm: The Secret Sauce for Better Mobile Apps

SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!
Ben Steinhauser
 

Ähnlich wie MongoDB .local Bengaluru 2019: Realm: The Secret Sauce for Better Mobile Apps (20)

Introduction to Realm Mobile Platform
Introduction to Realm Mobile PlatformIntroduction to Realm Mobile Platform
Introduction to Realm Mobile Platform
 
iOS Dev Happy Hour Realm - Feb 2021
iOS Dev Happy Hour Realm - Feb 2021iOS Dev Happy Hour Realm - Feb 2021
iOS Dev Happy Hour Realm - Feb 2021
 
MongoDB .local London 2019: Realm: The Secret Sauce for Better Mobile Apps
MongoDB .local London 2019: Realm: The Secret Sauce for Better Mobile AppsMongoDB .local London 2019: Realm: The Secret Sauce for Better Mobile Apps
MongoDB .local London 2019: Realm: The Secret Sauce for Better Mobile Apps
 
MongoDB World 2019: Realm: The Secret Sauce for Better Mobile Apps
MongoDB World 2019: Realm: The Secret Sauce for Better Mobile AppsMongoDB World 2019: Realm: The Secret Sauce for Better Mobile Apps
MongoDB World 2019: Realm: The Secret Sauce for Better Mobile Apps
 
LowlaDB intro March 2015
LowlaDB intro March 2015LowlaDB intro March 2015
LowlaDB intro March 2015
 
AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB
AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDBAWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB
AWS Webcast - Build Mobile Apps with a Secure, Scalable Back End on DynamoDB
 
Discovery Day 2019 Sofia - Big data clusters
Discovery Day 2019 Sofia - Big data clustersDiscovery Day 2019 Sofia - Big data clusters
Discovery Day 2019 Sofia - Big data clusters
 
Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto
Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto
Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto
 
Andy Malone - The new office 365 for it pro's
Andy Malone - The new office 365 for it pro'sAndy Malone - The new office 365 for it pro's
Andy Malone - The new office 365 for it pro's
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
 
What’s new in WSO2 Enterprise Integrator 6.6
What’s new in WSO2 Enterprise Integrator 6.6What’s new in WSO2 Enterprise Integrator 6.6
What’s new in WSO2 Enterprise Integrator 6.6
 
Microsoft Database Options
Microsoft Database OptionsMicrosoft Database Options
Microsoft Database Options
 
MongoDB .local Chicago 2019: REST-less Mobile Apps: Why Offline-first & Sync ...
MongoDB .local Chicago 2019: REST-less Mobile Apps: Why Offline-first & Sync ...MongoDB .local Chicago 2019: REST-less Mobile Apps: Why Offline-first & Sync ...
MongoDB .local Chicago 2019: REST-less Mobile Apps: Why Offline-first & Sync ...
 
ITB2017 - Keynote
ITB2017 - KeynoteITB2017 - Keynote
ITB2017 - Keynote
 
SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!SharePoint 2014: Where to save my data, for devs!
SharePoint 2014: Where to save my data, for devs!
 
FIWARE Wednesday Webinars - Architecting Your Smart Solution Powered by FIWARE
FIWARE Wednesday Webinars - Architecting Your Smart Solution Powered by FIWAREFIWARE Wednesday Webinars - Architecting Your Smart Solution Powered by FIWARE
FIWARE Wednesday Webinars - Architecting Your Smart Solution Powered by FIWARE
 
The web as it should be
The web as it should beThe web as it should be
The web as it should be
 
Building Rich Internet Apps with Silverlight 2
Building Rich Internet Apps with Silverlight 2Building Rich Internet Apps with Silverlight 2
Building Rich Internet Apps with Silverlight 2
 
containerd summit - Deep Dive into containerd
containerd summit - Deep Dive into containerdcontainerd summit - Deep Dive into containerd
containerd summit - Deep Dive into containerd
 
From 0 to syncing
From 0 to syncingFrom 0 to syncing
From 0 to syncing
 

Mehr von MongoDB

Mehr von MongoDB (20)

MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDBMongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series DataMongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your MindsetMongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & GolangMongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
 
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDBMongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
 
MongoDB .local Paris 2020: Tout savoir sur le moteur de recherche Full Text S...
MongoDB .local Paris 2020: Tout savoir sur le moteur de recherche Full Text S...MongoDB .local Paris 2020: Tout savoir sur le moteur de recherche Full Text S...
MongoDB .local Paris 2020: Tout savoir sur le moteur de recherche Full Text S...
 
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
MongoDB .local Paris 2020: Adéo @MongoDB : MongoDB Atlas & Leroy Merlin : et ...
 
MongoDB .local Paris 2020: Les bonnes pratiques pour travailler avec les donn...
MongoDB .local Paris 2020: Les bonnes pratiques pour travailler avec les donn...MongoDB .local Paris 2020: Les bonnes pratiques pour travailler avec les donn...
MongoDB .local Paris 2020: Les bonnes pratiques pour travailler avec les donn...
 
MongoDB .local Paris 2020: Devenez explorateur de données avec MongoDB Charts
MongoDB .local Paris 2020: Devenez explorateur de données avec MongoDB ChartsMongoDB .local Paris 2020: Devenez explorateur de données avec MongoDB Charts
MongoDB .local Paris 2020: Devenez explorateur de données avec MongoDB Charts
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Kürzlich hochgeladen (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

MongoDB .local Bengaluru 2019: Realm: The Secret Sauce for Better Mobile Apps

  • 1.
  • 2. Realm - The Secret Sauce for Better Mobile Apps Ankit Kakkar, Technical Services, MongoDB
  • 3.
  • 4. Expectations for Mobile Apps are high
  • 5. What is Realm? 1. Native on-device object database 2. Cloud service that allows seamless synchronization and sharing across devices
  • 6. The failed promise of ubiquitous connectivity • Even in major cities connectivity is spotty • Go to the countryside, still many places with no connectivity • Crises or huge events often takes down connectivity • Developing countries are the next big market, but there connectivity is even worse, and bandwidth is expensive How do you deal with this reality as a developer?
  • 7. Developer experience is key • A data model that fits seamlessly with the platform and programming language • Transparent synchronization that just works • A conflict resolution model that works both in realtime, and when users are offline for extended periods of time
  • 8. Realm is a mobile database
  • 9. Cross-platform Operating Systems Languages/Platforms Realm’s open-source on-device database: • Usage: 100k+ developers; 65% of Fortune 1000; 2B+ app installs • 50k+ Github stars • 18k+ Twitter followers • Active community involvement
  • 11.
  • 12. Leverage Sync: MobileServer Realtime data sync Create a persistent shared state
  • 13. Realm Mobile Database • Offline-first API • Object interface with native support for relationships • Change notifications keep UI up-to-date • Abstracts network handling • Removes (de)serialization • Built-in encryption
  • 14. Realm Sync Server • Realtime sync • Automatic conflict resolution • Flexible schema change support • Event handling • Integrate existing infrastructure • Supports data push
  • 15. Realm Sync characteristics • Write to (synced) DB = implicit syncing No sync specific code to write. • Persistent Connection (web socket) • Deterministic & Strong Eventually consistent conflict resolution • Native event handling & data push. • Efficient data exchange - Only diff (field level) - Compressed Binary format • Two modalities: - Sync full shared data-set (full sync) - Subscribe to sub-set (Query-based sync)
  • 16. Realm is an object database
  • 17. An Object Database • Represents an instance of a Realm database container (can be a file, or in memory) • Data internally represented and exposed as objects • Relations are linked lists / pointers • Cross platform • ACID compliant, performant
  • 18. Native objects map directly to the database public class Dog extends RealmObject { private String name; private int age; // ... Generated getters and setters ... } public class Person extends RealmObject { @PrimaryKey private long id; private String name; private RealmList<Dog> dogs; // Declare one-to-many relationships // ... Generated getters and setters ... }
  • 19. Relationships // persons => [U1,U2] RealmResults<Person> persons = realm.where(Person.class) .equalTo("dogs.color", "Brown") .findAll();
  • 20. Query across the object graph // Query using a predicate string let johnsDogs = realm.objects(Dog.self).filter(”owner.name = 'John'") // Query using an NSPredicate let predicate = NSPredicate(format: "color = %@ AND name BEGINSWITH %@", "tan", "B") let tanDogs = realm.objects(Dog.self).filter(predicate) // Sort tan dogs with names starting with "B" by name let sortedDogs = realm.objects(Dog.self).filter("color = 'tan' AND name BEGINSWITH 'B'”) .sorted(byKeyPath:"name")
  • 21. Easy and safe multi-threading with transactions // create new object let person = Person(name: "Jane") // add to realm in transaction try! realm.write { realm.add(person) }
  • 22. Realm objects has a special capability…
  • 23. Objects and queries live-update in response to changes // Query Realm for all dogs less than 2 years old let puppies = realm.objects(Dog.self).filter("age < 2") puppies.count // => 0 because no dogs have been added to the Realm yet // Persist your data easily try! realm.write { let myDog = Dog(name: “Fido”, age: 1) realm.add(myDog) } // Queries are updated in realtime puppies.count // => 1
  • 24. Realm is a live object database
  • 25. Bind directly to components for reactive UI // Observe Results Notifications notificationToken = results.observe { [weak self] (changes: RealmCollectionChange) in guard let tableView = self?.tableView else { return } switch changes { case .initial: tableView.reloadData() case .update(_, let deletions, let insertions, let modifications): // Query results have changed, so apply them to the UITableView tableView.beginUpdates() tableView.insertRows(at: insertions.map({ IndexPath(row: $0, section: 0) }), with: .automatic) tableView.deleteRows(at: deletions.map({ IndexPath(row: $0, section: 0)}), with: .automatic) tableView.reloadRows(at: modifications.map({ IndexPath(row: $0, section: 0) }), with: .automatic) tableView.endUpdates() case .error(let error): }
  • 26. Backend integration § Event handling § Listen and respond to changes from clients § Pass along data to other systems or databases § Connectors to 3rd party databases § Two-way sync to legacy databases § Postgres and SQL Server. MongoDB coming! § Integrations (via Node.js & .NET SDK) § Identical object interface § Full database capabilities § Apply changes to push data § Mobilize legacy APIs § An easier way to integrate legacy data with mobile devices § Keep complexity in backend
  • 27. Make a synced Realm with one line change • Instead of a file path, specify a URL pointing to the realm in the cloud. • Exactly the same as a local realm, but now with background synchronization. // Create the configuration SyncUser user = SyncUser.currentUser(); String url = "realms://myinstance.cloud.realm.io/~/userRealm"; SyncConfiguration config = user.createConfiguration(url).build(); // Open the remote Realm Realm realm = Realm.getInstance(config); // Any changes made to this Realm will be synced across all devices
  • 28. Realm + MongoDB Realm Mobile (Database & Sync) QueryAnywhere Functions MongoDB Realm (“Stitch”) Realm Sync MongoDB Atlas Rules
  • 29. Digital Transformation Use Case Food Services Companies • Real-time Inventory updates at meal purchase • Reliable (offline) inventory reconciliation (think “walk-in” fridge) • Synchronize supply catalog & meal planning • Automated order submit Result: Highly Automated Process Flow
  • 30. Digital Transformation Use Case Flight Management / Reporting Pilot & Crew focused: • Crew management: • Scheduling • Check-in/out • Flight tracking • Fuel, Speed • Event Logging, Incident tracking Result: Replacing lots of paperwork!
  • 31. Digital Transformation Use Case Major Cruise Vacation Company • Food/Drink orders management: • Order capture, Bar workflow, • Fulfillment tracking (Billing) • Excursion Pre-booking • Each On-Island ‘Activity’ has their dedicated device with synced booking info • Check-in, up-sells synced locally, • Fulfillment tracking (for Billing) Result: automated & simplified communication “Ship-to-shore”
  • 32. Digital Transformation Use Case National Police Force (Europe) Realtime empowered Police Force • Enable Chat & Messaging amongst force members • Evidence and Note capture (shared) • Task sharing, team assignment • Everything realm-time & offline Results: (under development)