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

Building_Native_Apps_with_Codesharing_using_Mon...

 Building_Native_Apps_with_Codesharing_using_MongoDB___KotlinMultiplatform___GDG_Warsaw___MUG_.pdf

Link to GitHub used at the presentation: https://github.com/mongodb-developer/Conference-Queries-App.

Mohit Sharma

May 29, 2023
Tweet

More Decks by Mohit Sharma

Other Decks in Programming

Transcript

  1. Building Native apps with MongoDB & Kotlin Multiplatform Mohit Sharma

    Developer Advocate, MongoDB codeWithMohit MongoDB
  2. Hi, I’m Mohit 👋 MongoDB, Dublin Developer Advocate Dubizzle (Olx),

    Dubai Mobile Evangelist and few more.. codeWithMohit
  3. Agenda • Why KMM ? • What is Data layer

    ? • How does MongoDB fit in? • Coding • Q & A @codeWithMohit
  4. Views ViewModels / Presenter XML/Storyboard Compose/SwiftUI etc Datasource Logic layer

    (optional) High Level Architecture Local Cloud @codeWithMohit
  5. Evolution Evilution Repo Cache Database Network API 3.1 API 3.2

    API 2.1 API 2.2 API 1.1 API 1.2 API xx API xx API xx API xx API xx API xx API xx API xx @codeWithMohit
  6. Data synchronization JSON NATIVE OBJECT MSG QUEUE BACKEND OBJECT REST

    CALL TO API PUSH SERVICE PUSH NOTIFICATION COMPLEX CONFLICT RESOLUTION, RETRY & ERROR HANDLING POTENTIAL APP CRASH OFFLINE? INVALID DATA? SERVER ERROR? TIMED OUT? Backend database Mobile devices with local data Data Layer is a hard & complex problem !! WRITE CONFLICTS? @codeWithMohit
  7. App dataflow with MongoDB Out-of-the-box device-cloud synchronization Mobile-optimized database Ultra-lightweight

    and fast Object-oriented No ORM or DAO required Advanced security and permissions Built-in conflict resolution The leading developer data platform on the cloud Functions Triggers GraphQL DataAPI Data Access Control Atlas Realm KMM SDK Atlas Device Sync Search Charts Time Series @codeWithMohit
  8. Realm Reactive Notifications Built-in Encryption Offline-First, Background Sync Object Schema

    & Relationships Simple to Learn & Master Idiomatic Query Language
  9. Realm By MongoDB • Free and Open Source Database •

    Founded 2011. First release in 2014 • C++ with Language SDK’s on top • Part of MongoDB since 2019
  10. Realm Query Language • alwaysFalse • alwaysTrue • and •

    beginGroup • beginsWith • between • contains • distinct • endsWith • endGroup • equalTo • greaterThan • greaterThanOrEqual • in • isEmpty • isNotEmpty • isNotNull • isNull • lessThan • lessThanOrEqual • like • limit • maximumDate • minimumDate • not • notEqualTo • or • sort • average • count • sum • max • min @codeWithMohit
  11. Atlas Device Sync Local and offline data access with fast,

    efficient device to cloud sync @codeWithMohit
  12. Realm MongoDB Atlas Recap 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 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 Object Conversion Atlas Device Sync automatically converts the Realm object to a MongoDB document Notification Realm commits the change to disk. A notification is fired and the UI is updated displaying the new change to the user