Slide 1

Slide 1 text

Mohit Sharma Developer Advocate,MongoDB @codeWithMohit NoSQL database for Mobile Apps WELCOME

Slide 2

Slide 2 text

Why NoSQL DB ? DB + NoSQL @codeWithMohit

Slide 3

Slide 3 text

How many brave souls here ? Ref: https://www.couchbase.com/blog/wp-content/uploads/2021/05/data-model-sql-to-json.png

Slide 4

Slide 4 text

How many lucky? @codeWithMohit

Slide 5

Slide 5 text

Response Json is update! @codeWithMohit

Slide 6

Slide 6 text

App developers @codeWithMohit

Slide 7

Slide 7 text

Repo ? Repo Cache Database Network

Slide 8

Slide 8 text

Evolution Repo Cache Database Network API 1 API 2 @codeWithMohit

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

Occupational Hazard @codeWithMohit

Slide 11

Slide 11 text

Do more! @codeWithMohit

Slide 12

Slide 12 text

Possible future? @codeWithMohit

Slide 13

Slide 13 text

Introspect @codeWithMohit

Slide 14

Slide 14 text

Realm MongoDB @codeWithMohit

Slide 15

Slide 15 text

Realm Reactive Notifications Built-in Encryption Offline-First, Background Sync Object Schema & Relationships Simple to Learn & Master Idiomatic Query Language

Slide 16

Slide 16 text

Realm History ● Free and Open Source Database ● Founded 2011. First release in 2014 ● C++ with Language SDK’s on top ● Part of MongoDB since 2019 By MongoDB

Slide 17

Slide 17 text

Realm By MongoDB

Slide 18

Slide 18 text

Realm Object Classes are the Schema class Dog : RealmObject { var name: String = "" var age: Int = 0 } class Person : RealmObject { var name: String = "" var dog: Dog? = null var puppies: RealmList = RealmList() } @codeWithMohit

Slide 19

Slide 19 text

Relationships class Person : RealmObject { var name: String = "" var dog: Dog? = null var puppies: RealmList = RealmList() var tags: RealmMap = RealmMap() var activities: RealmSet = RealmSet() } @codeWithMohit

Slide 20

Slide 20 text

Realm // Minimal configuration val config = RealmConfiguration.with(schema = setOf(Person::class, Dog::class)) // Extended Configuration val config2 = RealmConfiguration.Builder(schema = setOf(Person::class, Dog::class)) .name("my-realm.realm") .deleteRealmIfMigrationNeeded() .build() // Opening a Realm val realm = Realm.open(config) // Closing a Realm (not strictly needed) realm.close() @codeWithMohit

Slide 21

Slide 21 text

Realm // Minimal configuration val config = RealmConfiguration.with(schema = setOf(Person::class, Dog::class)) // Extended Configuration val config2 = RealmConfiguration.Builder(schema = setOf(Person::class, Dog::class)) .name("my-realm.realm") .deleteRealmIfMigrationNeeded() .build() // Opening a Realm val realm = Realm.open(config) // Closing a Realm (not strictly needed) realm.close() @codeWithMohit

Slide 22

Slide 22 text

Encryption & Schema Migration ● Automatic Migration for basic use-case like Addition or deletion. ● Single call API for encrypting complete database. @codeWithMohit

Slide 23

Slide 23 text

Realm // Minimal configuration val config = RealmConfiguration.with(schema = setOf(Person::class, Dog::class)) // Extended Configuration val config2 = RealmConfiguration.Builder(schema = setOf(Person::class, Dog::class)) .name("my-realm.realm") .deleteRealmIfMigrationNeeded() .build() // Opening a Realm val realm = Realm.open(config) // Closing a Realm (not strictly needed) realm.close() @codeWithMohit

Slide 24

Slide 24 text

Dependency Injection val koinModule = module { single { RealmConfiguration.with(schema = setOf(Person::class)) } single { Realm.open(get()) } } class MyRepository : KoinComponent { val realm: Realm by inject() } @codeWithMohit

Slide 25

Slide 25 text

Queries val id = "my-id" val realm: Realm by inject() val results: RealmResults = realm.query("id = ${id}") @codeWithMohit

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

Realm Query langua ge Realm Query language @codeWithMohit

Slide 28

Slide 28 text

Listen for & React to changes in data val myPuppy = realm.query("age”, “1").first().find() // Observe Realm Notifications myDog.asFlow().map{ when(it){ is InitialResults -> TODO() is UpdatedResults -> TODO() } } // Update the puppy’s age to see the effect realm.write { myPuppy.age = 3 } @codeWithMohit

Slide 29

Slide 29 text

Realm Studio @codeWithMohit

Slide 30

Slide 30 text

Half win!

Slide 31

Slide 31 text

Half win!

Slide 32

Slide 32 text

Atlas Device Sync Out of the box device-cloud synchronization Atlas Database Atlas Device Sync Mobile App @codeWithMohit

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Sync Conflict Resolution Offline client deletes User1 Driver adds User3 and updates User2’s number t0 t1 Sync Changes t2 Sync Changes t2 Send Merged Changes t4 Send Merged Changes t4 Apply Conflict Resolution Rules t3 Delete Always Wins MongoDB Device Sync Last Update Wins Inserts in lists are ordered by time MongoDB Atlas Realm Sync Client Final State User List |- user0 : 000 |- user2 : 999 |- user3 : 003 Initial State User List |- user0 : 000 |- user1 : 001 |- user2 : 002

Slide 36

Slide 36 text

Thatʼs not all ! 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 Kotlin SDK Atlas Device Sync Search Charts Time Series @codewithMohit

Slide 37

Slide 37 text

Leading innovators leverage MongoDBʼs mobile & device solution

Slide 38

Slide 38 text

Scan to QR code to win cool Realm & MongoDB Swags

Slide 39

Slide 39 text

Thank you for your time. codeWithMohit