Slide 1

Slide 1 text

Realm A new way to persist & query data on React Native Nabil Hachicha @nabil_hachicha

Slide 2

Slide 2 text

Realm +

Slide 3

Slide 3 text

AsyncStorage getItem(key, callback)
 
 setItem(key, value /* string */, callback)
 
 removeItem(key, callback)
 
 // etc.

Slide 4

Slide 4 text

SQLite SELECT * 
 FROM persons p
 INNER JOIN persons c ON c.parent_id = p.id ORDER BY name

Slide 5

Slide 5 text

Realm is a mobile database hundreds of millions of people rely on

Slide 6

Slide 6 text

+

Slide 7

Slide 7 text

class Person {
 ...
 }
 
 Person.schema = {
 name: 'Person',
 properties: {
 name: 'string',
 birthday: ‘date'
 }
 }; Realm is not an ORM

Slide 8

Slide 8 text

// Query results are computed lazily
 let people = realm.objects('Person');
 
 
 
 
 
 


Slide 9

Slide 9 text

// Query results are computed lazily
 let people = realm.objects('Person');
 
 // and can be filtered
 people = people.filtered('birthday < $0', date);
 
 
 


Slide 10

Slide 10 text

// Query results are computed lazily
 let people = realm.objects('Person');
 
 // and can be filtered
 people = people.filtered('birthday < $0', date); 
 // and sorted
 people = people.sorted('name');


Slide 11

Slide 11 text

Models

Slide 12

Slide 12 text

Models Basic Property

Slide 13

Slide 13 text

Models Basic Property Object Property

Slide 14

Slide 14 text

Models Basic Property Object Property List Property

Slide 15

Slide 15 text

Basic Property Types • bool => Boolean • int, float, double => Number • string => String • data => ArrayBuffer • date => Date

Slide 16

Slide 16 text

Object Properties Many-to-One

Slide 17

Slide 17 text

List Properties Many-to-Many

Slide 18

Slide 18 text

Optional Properties

Slide 19

Slide 19 text

Default Property Values

Slide 20

Slide 20 text

Indexed Properties

Slide 21

Slide 21 text

Primary Keys

Slide 22

Slide 22 text

Writes

Slide 23

Slide 23 text

Writes All changes to an object (addition, modification & deletion) must be done within a write transaction.

Slide 24

Slide 24 text

Creating Objects

Slide 25

Slide 25 text

Updating Objects

Slide 26

Slide 26 text

Deleting Objects

Slide 27

Slide 27 text

Query

Slide 28

Slide 28 text

Query

Slide 29

Slide 29 text

Filtering

Slide 30

Slide 30 text

Filtering

Slide 31

Slide 31 text

Auto-Updating Results

Slide 32

Slide 32 text

Change Events

Slide 33

Slide 33 text

ListView Integration import { ListView } from 'realm/react-native';
 
 // - Same API as React.ListView
 // - Optimized for Realm collections


Slide 34

Slide 34 text

Encryption

Slide 35

Slide 35 text

Under The Hood

Slide 36

Slide 36 text

Multi-Version-Concurrency-Control

Slide 37

Slide 37 text

Multi-Version-Concurrency-Control

Slide 38

Slide 38 text

Multi-Version-Concurrency-Control

Slide 39

Slide 39 text

• Zero-Copy Architecture • Bitpacking reduces memory usage by up to 90% • Caching & Vectorization makes access faster than native C • Universal data representation from multiple languages

Slide 40

Slide 40 text

Inserts Counts Queries Realm SQLite

Slide 41

Slide 41 text

Open Source on https://github.com/realm/realm-js

Slide 42

Slide 42 text

npm install realm https://realm.io https://github.com/realm/realm-js @realm [email protected]

Slide 43

Slide 43 text

Thank You! @nabil_hachicha https://realm.io/jobs