Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Intro to MongoDB for Mobile developer

Intro to MongoDB for Mobile developer

MongoDB is often perceived as just a database but it's much more than that. In this session, we cover the basics of MongoDB and how to build mobile apps using it.

Mohit Sharma

January 25, 2023
Tweet

More Decks by Mohit Sharma

Other Decks in Technology

Transcript

  1. This webinar will be recorded — the recording will be

    shared. Logistics All participants will be muted. For questions during & at the end of the session, please use the Q&A box. For live comments, please use the Chat in the control panel. There will be a short survey at the end - your input is appreciated :)
  2. Agenda MongoDB: More Than Just a Database! MongoDB and the

    Document Model Querying MongoDB Let's Build a Mobile App! Q&A (fill in the survey!)
  3. A developer data platform to simplify working with data Elegant

    developer experience Serve any application or workload Modern data model Abstraction of infrastructure details
  4. End-to-end, enterprise-grade security features Realm MongoDB Atlas Atlas Device Sync

    In-cloud security: Features that integrate with your existing protocols and compliance standards. • Encrypted storage volumes • Network isolation • Role-based access management On-device encryption: Easily encrypt PII in realm database files with the encryption APIs Authorization: Rich authorization methods including anonymous, email/password, API key, Custom Function, Custom JWT, Facebook, Google, and Apple. In-flight encryption: All network traffic is encrypted using Transport layer Security (TLS). Granular permissions: Document and field-level access permissions are used to dynamically determine the data synced to the device. ISO SOC PCI CSA HIPAA HITRUST VPAT GDPR On-device In-flight In the cloud
  5. Atlas & App Services Database Realm Database Atlas Device Sync

    GraphQL Data API Functions Atlas Search Drivers
  6. { "_id": ObjectId("573a1390f29313caabcd4135"), "title": "Blacksmith Scene", "plot": "Three men hammer

    on an anvil and pass ...", "cast": [ "Charles Kayser", "John Ott" ], "directors": [ "William K.L. Dickson" ], "lastupdated": "2015-08-26 00:03:50.133000000", "year": 1893, "imdb": { "rating": 6.2, "votes": 1189, "id": 5 } } A Document
  7. { "_id": ObjectId("573a1390f29313caabcd4135"), "title": "Blacksmith Scene", "plot": "Three men hammer

    on an anvil and pass ...", "cast": [ "Charles Kayser", "John Ott" ], "directors": [ "William K.L. Dickson" ], "lastupdated": "2015-08-26 00:03:50.133000000", "year": 1893, "imdb": { "rating": 6.2, "votes": 1189, "id": 5 } } A Document
  8. { "_id": ObjectId("573a1390f29313caabcd4135"), "title": "Blacksmith Scene", "plot": "Three men hammer

    on an anvil and pass ...", "cast": [ "Charles Kayser", "John Ott" ], "directors": [ "William K.L. Dickson" ], "lastupdated": "2015-08-26 00:03:50.133000000", "year": 1893, "imdb": { "rating": 6.2, "votes": 1189, "id": 5 } } A Document
  9. { "_id": ObjectId("573a1390f29313caabcd4135"), "title": "Blacksmith Scene", "plot": "Three men hammer

    on an anvil and pass ...", "cast": [ "Charles Kayser", "John Ott" ], "directors": [ "William K.L. Dickson" ], "lastupdated": "2015-08-26 00:03:50.133000000", "year": 1893, "imdb": { "rating": 6.2, "votes": 1189, "id": 5 } } Values Can be Scalar
  10. { "_id": ObjectId("573a1390f29313caabcd4135"), "title": "Blacksmith Scene", "plot": "Three men hammer

    on an anvil and pass ...", "cast": [ "Charles Kayser", "John Ott" ], "directors": [ "William K.L. Dickson" ], "lastupdated": "2015-08-26 00:03:50.133000000", "year": 1893, "imdb": { "rating": 6.2, "votes": 1189, "id": 5 } } Array Values
  11. { "_id": ObjectId("573a1390f29313caabcd4135"), "title": "Blacksmith Scene", "plot": "Three men hammer

    on an anvil and pass ...", "cast": [ "Charles Kayser", "John Ott" ], "directors": [ "William K.L. Dickson" ], "lastupdated": "2015-08-26 00:03:50.133000000", "year": 1893, "imdb": { "rating": 6.2, "votes": 1189, "id": 5 } } Subdocument Values
  12. db.collection.findOne() Match a single document. db.collection.find() Match, sort, or count

    multiple documents. db.collection.aggregate() Match, combine & aggregate documents. The MongoDB Query API
  13. { "_id": { "$oid": "573a1390f29313caabcd4135" }, "plot": "Three men hammer

    on an anvil and pass a bottle of beer around.", "genres": [ "Short" ], "runtime": 1, "cast": [ db.movies.findOne({ "title": "Blacksmith Scene" }) Find One Document
  14. db.movies.find({ "year": 2010 }); [{ "_id": { "$oid": "573a139cf29313caabcf6fb1" },

    "plot": "A lonely obese nurse, working at a hospital terminal ward, is reminded of her childhood friend Adrienn Pal and wants to track her down.", "genres": [ "Drama" ], "runtime": 136, "cast": [ "èva Gèbor", "Istvèn Znamenèk", "èkos Horvèth", "Lia Pokorny" ], "num_mflix_comments": 1, Find Many Documents
  15. db.movies.find({ "year": { "$gte": 2000, "$lt": 2010 } }) [{

    "_id": { "$oid": "573a139cf29313caabcf6fb1" }, "plot": "A lonely obese nurse, working at a hospital terminal ward, is reminded of her childhood friend Adrienn Pal and wants to track her down.", "genres": [ "Drama" ], "runtime": 136, "cast": [ "èva Gèbor", "Istvèn Znamenèk", "èkos Horvèth", "Lia Pokorny" ], "num_mflix_comments": 1, Find Many Documents
  16. And there's more… • Aggregation queries • Optimize your queries

    with indexes • Ensure consistency with transactions • Store geographical data with GeoJSON • Store metrics with time series collections
  17. Data synchronization JSON ORM NATIVE OBJECT MSG QUEUE BACKEND OBJECT

    REST CALL TO API COMPLEX NETWORK HANDLING & CONFLICT RESOLUTION POTENTIAL APP CRASH OFFLINE? INVALID DATA? SERVER ERROR? TIMED OUT? Backend database Mobile devices with local data High Level Architecture
  18. High Level Architecture Mobile App Atlas Device Sync MongoDB Atlas

    Live Update Realm Mobile DB Registration/Login Create Events Manage Talks
  19. Mobile App Atlas Device Sync MongoDB Atlas Live Update Realm

    Mobile DB Registration/Login Create Events Manage Talks How to connect to our Atlas Database?
  20. How to a connect client apps with Atlas App Service?

    Realm SDK Swift/SwiftUI Dart/Flutter Kotlin/KMM Java JavaScript .NET
  21. Realm By MongoDB ACID Object database Easy in-language model definitions

    Notification Encryption Sync with MongoDB Atlas Fast w/ Zero-copy and lazy loading
  22. How to a connect Mobile App with Atlas App? Code

    snippet for setting up connection with Atlas App
  23. How to a connect Mobile App with Atlas App? Code

    snippet for setting up connection with Atlas App
  24. Realm MongoDB Atlas MongoDB auto-syncs between device and cloud Atlas

    Device Sync SDK writes transaction The Realm SDK writes the transaction, commiting the object to disk, and sends the changes to the server Insert into collection MongoDB document inserted into the Atlas collection User makes change User logs into the app and makes an edit Object Conversion Atlas Device Sync automatically converts the Realm object to a MongoDB document Change Detected Document changed by another user is picked up by changeStreams and forwarded to Atlas Device Sync Object Conversion Atlas Device Sync automatically translates MongoDB documents to Realm objects and syncs down to the device Notification Realm commits the change to disk. A notification is fired and the UI is updated displaying the new change to the user
  25. MongoDB provides the easiest way to build & scale mobile

    apps Built-in cloud sync, conflict resolution, security, & permissions Mobile database with built-in ORM and network handling MongoDB’s cloud database Atlas Realm Atlas Device Sync Swift/SwiftUI Dart/Flutter Kotlin/KMM Java JavaScript .NET
  26. And provides a single data layer shared across all platforms

    Built-in cloud sync, conflict resolution, security, & permissions MongoDB’s cloud database Atlas Atlas Device Sync