Slide 1

Slide 1 text

Part 2: RMP Overview & Demo for Realm Meetup #10 Eunjoo Im [email protected]

Slide 2

Slide 2 text

Realm Mobile Database - API Realm Mobile Platfrom - ѐਃ - ҳࢿ - Demo [email protected]

Slide 3

Slide 3 text

[email protected] Realm Mobile Platform

Slide 4

Slide 4 text

Realm Mobile Database with Live Objects [email protected]

Slide 5

Slide 5 text

Realm Mobile Database Objects Queries Notifications Transactions UI events, Network, more Modify Make Up Trigger [email protected]

Slide 6

Slide 6 text

Objects Objects Queries Notifications Transactions UI events, Network, more Modify Make Up Trigger [email protected]

Slide 7

Slide 7 text

Objects Queries Notifications Transactions UI events, Network, more Modify Make Up Trigger [email protected]

Slide 8

Slide 8 text

Queries Objects Queries Notifications Transactions UI events, Network, more Modify Make Up Trigger [email protected]

Slide 9

Slide 9 text

Objects Queries Notifications Transactions UI events, Network, more Modify Make Up Trigger [email protected]

Slide 10

Slide 10 text

Notifications Objects Queries Notifications Transactions UI events, Network, more Modify Make Up Trigger [email protected]

Slide 11

Slide 11 text

Objects Queries Notifications Transactions UI events, Network, more Modify Make Up Trigger [email protected]

Slide 12

Slide 12 text

Transactions Objects Queries Notifications Transactions UI events, Network, more Modify Make Up Trigger [email protected]

Slide 13

Slide 13 text

Objects Queries Notifications Transactions UI events, Network, more Modify Make Up Trigger [email protected]

Slide 14

Slide 14 text

Realm Mobile Platform पदр জਸ ਤೠ ؘ੉ఠ زӝച৬ ഈস ӝמ [email protected]

Slide 15

Slide 15 text

REST API۽ ࢲߡ ాन [email protected]

Slide 16

Slide 16 text

ӝઓ ؘ੉ఠ ాन Native object JSON Backend object SQL Backend object JSON Native object SQLite/CoreData SQLite/CoreData e.g. REST, Parse, etc. Realm Mobile Database Realm Object Server Only Realm RMP vs. REST/JSON REST call Push Notification [email protected]

Slide 17

Slide 17 text

Native object JSON Backend object SQL Backend object JSON Native object SQLite/CoreData SQLite/CoreData e.g. REST, Parse, etc. Realm Mobile Database Realm Object Server Only Realm REST call Push Notification Realm REST/JSON [email protected]

Slide 18

Slide 18 text

Native object JSON Backend object SQL Backend object JSON Native object SQLite/CoreData SQLite/CoreData e.g. REST, Parse, etc. Realm Mobile Database Realm Object Server Only Realm Realm REST call Push Notification REST/JSON [email protected]

Slide 19

Slide 19 text

੉۠ জ ҳઑܳ [email protected]

Slide 20

Slide 20 text

੉ۧѱ ߄Ըפ׮! [email protected]

Slide 21

Slide 21 text

؊ ݆਷ ࢲߡ ӝמ • Realm Database SDK • ੋૐ • ঐഐചػ ੹࣠ • पदр زӝച • ୽ج ೧Ѿ • ࣻز ߔস • ࢲߡஏ ੉߮౟ ೩ٜ݂ • ݽפఠ݂ • ؘ੉ఠ ੽Ӕ • Ҋоਊࢿ • ۽٘ ߖ۠य • ࣻಣ झாੌ݂ • োࣘ ߔস [email protected] PE EE DE

Slide 22

Slide 22 text

Realm Mobile Platform ҳࢿ ࢸݺ [email protected]

Slide 23

Slide 23 text

- Realm ਬഋ - ӂೠ (ACL) - Realm Functions [email protected]

Slide 24

Slide 24 text

[email protected] ۽ஸ Realm vs زӝ Realm Realm য়࠳ં౟ ࢲߡ

Slide 25

Slide 25 text

[email protected] زӝ Realm • ӝઓ Realmҗ زੌೞѱ ੘زೞݴ ߔӒۄ਍٘ زӝച ӝמ ನೣ • Configurationীࢲ Sync ࢸ੿ // ࢸ੿ ࣇস let syncServerURL = URL(string: "realm://localhost:9080/~/userRealm")! let config = Realm.Configuration(syncConfiguration: SyncConfiguration(user: user, realmURL: syncServerURL)) // ਗѺ Realm ৌӝ let realm = try! Realm(configuration: config)

Slide 26

Slide 26 text

[email protected] زӝ Realm ਬഋ ҕਊ Realm ѐੋ Realm • ݽٚ ࢎਊ੗о ࠅ ࣻ ੓਺ • ࢎਊ੗ח ੍ӝ ӂೠ݅ ࠗৈ • ౠ੿ ࢎਊ੗о ࣗਬ੗ • ׮ܲ ࢎਊ੗ী ӂೠ ࠗৈ ҕਬ Realm

Slide 27

Slide 27 text

[email protected] ࣳೝށ दաܻয় ઁಿ ݾ۾ ࣳೝ ܻझ౟ ੢߄ҳפ ҕਊ Realm ѐੋ Realm • ݽٚ ࢎਊ੗о ࠅ ࣻ ੓਺ • ࢎਊ੗ח ੍ӝ ӂೠ݅ ࠗৈ • ౠ੿ ࢎਊ੗о ࣗਬ੗ • ׮ܲ ࢎਊ੗ী ӂೠ ࠗৈ ҕਬ Realm

Slide 28

Slide 28 text

[email protected] ҕਊ Realm Realm য়࠳ં౟ ࢲߡ userA: ੍ӝ ӂೠ userB: ੍ӝ ӂೠ /productCatalog /productCatalog ؘ੉ఠ ಹद /productCatalog ؘ੉ఠ ಹद /productCatalog ؘ੉ఠ ಹद userC: ੍ӝ ӂೠ

Slide 29

Slide 29 text

[email protected] ѐੋ Realm /userA/cart Realm য়࠳ં౟ ࢲߡ userA: য٘޹ ӂೠ userB: য٘޹ ӂೠ নߑೱ زӝച /userB/cart /userA/cart /userB/cart নߑೱ زӝച

Slide 30

Slide 30 text

[email protected] ѐੋ-ҕਬ Realm /userA/shoppingList /userA/shoppingList Realm য়࠳ં౟ ࢲߡ নߑೱ زӝച /userA/shoppingList userA: য٘޹ ӂೠ userB: ੍ӝ/ॳӝ ӂೠ নߑೱ زӝച

Slide 31

Slide 31 text

[email protected] Realm য়࠳ં౟ ࢲߡ ҳઑ /userA/shoppingList /userA/cart /userB/cart /userC/cart /productCatalog userA userB userC /

Slide 32

Slide 32 text

[email protected] زӝ ࢎਊ੗ • ࢎਊ੗ ID۽ п Realm ҳ߹ য٘޹ ੌ߈

Slide 33

Slide 33 text

[email protected] ҕਊ/ѐੋ Realm ҕਊ ѐੋ ӂೠ ҙܻ

Slide 34

Slide 34 text

[email protected] Grant permission // ߸҃ೡ ਗѺ Realm URL let permissionChange = SyncPermissionChange(realmURL: realmURL, userID: anotherUserID, // ߸҃ೡ ࢎਊ੗ ID mayRead: true, // ੍ӝ ӂೠ ࠗৈ mayWrite: true, // ॳӝ ӂೠ ࠗৈ mayManage: false) // ҙܻ ӂೠ ޷ࠗৈ let managementRealm = try! user.managementRealm() try! managementRealm.write { managementRealm.add(permissionChange) } • mayRead: ੍ӝ ӂೠ • mayWrite: ॳӝ ӂೠ • mayManage: ҙܻ ӂೠ

Slide 35

Slide 35 text

[email protected] __admin Realm

Slide 36

Slide 36 text

Function য়࠳ં౟ ࢲߡ੄ Ӗ۽ߥ ܻझ׬ API۽ ഐ୹غҊ changeEvent ё୓ܳ ੹׳ೞח Node.js ೣࣻ [email protected] Realm FunctionsBeta झ௼݀౟ ௑ࣛ ۽Ӓ ܻझ׬ೡ Realm प೯/੷੢/࢏ઁ

Slide 37

Slide 37 text

[email protected] Realm FunctionsBeta

Slide 38

Slide 38 text

Realm Mobile Platform DEMO [email protected]

Slide 39

Slide 39 text

[email protected] Overview Server-side Realms Device-side Realms Realm Object Server Real-time Sync event-realm question-realmXX Users (Web) Managers (app)

Slide 40

Slide 40 text

Slide 41

Slide 41 text

[email protected] models (user web) let QuestionSchema = { name: 'Question', primaryKey: 'id', properties: { id: 'int', status: {type: 'bool', default: true}, date: 'date', question: 'string', author: {type: 'User'}, votes: {type: 'list', objectType: 'User'}, voteCount: 'int', isAnswered: {type: 'bool', default: false}, } } let UserSchema = { name: 'User', primaryKey: 'id', properties: { id: 'string' } } question-realmXX

Slide 42

Slide 42 text

[email protected] Login and create user Realm.Sync.User.login(SERVER_URL, user, password, (error, user) => { if (!error) { let syncRealm = new Realm({ sync: { user: user, url: QUEST_SERVER_URL, }, schema: [UserSchema] }); syncRealm.write(() => { newAuthor = syncRealm.create('User', {id: sess.author}, true) }); } });

Slide 43

Slide 43 text

[email protected] edit question syncRealm.write(() => { syncRealm.create('Question', {id: qid, question:question, date: date}, true) });

Slide 44

Slide 44 text

Slide 45

Slide 45 text

[email protected] models (admin app) class Event: Object { dynamic var id = 0 dynamic var status = true dynamic var date = Date() dynamic var name = "" } class Question: Object { dynamic var id = 0 dynamic var status = true dynamic var date = Date() dynamic var question = "" dynamic var author: User? var votes = List() dynamic var voteCount = 0 dynamic var isFavorite = false dynamic var isAnswered = false } class User: Object { dynamic var id = "" override static func primaryKey() -> String? { return "id" } } event-realm question-realmXX

Slide 46

Slide 46 text

func application(_ application: UIApplication,
 didFinishLaunchingWithOptions launchOptions:
 [UIApplicationLaunchOptionsKey: Any]?) -> Bool { window = UIWindow(frame: UIScreen.main.bounds) if configureDefaultRealm() { window?.rootViewController = viewController } else { window?.rootViewController = UIViewController() logIn(animated: false) } return true } [email protected] Login func configureDefaultRealm() -> Bool { if let user = SyncUser.current { SyncManager.shared.errorHandler = { error, session in if let authError = error as? SyncAuthError, authError.code == .invalidCredential { authenticationFailureCallback?() } } return true } return false }

Slide 47

Slide 47 text

[email protected] Create Event & Question Realm let syncServerURL = Constants.syncEventURL let config = Realm.Configuration(syncConfiguration: SyncConfiguration(user: SyncUser.current!, realmURL: syncServerURL)) let newEvent = Event(value: [eid, true, Date(), name]) try! realm.write { realm.add(newEvent) } // update event name let eventRealm = try! Realm(configuration: config) try! eventRealm.write { newEvent.name = name } // make question-xx Realm let baseURL = “\ (Constants.syncQuestionURL)\(String(eid))” let syncServerURL = URL(string: baseURL)! let config = Realm.Configuration(syncConfiguration: SyncConfiguration(user: SyncUser.current!, realmURL: syncServerURL)) let realm = try! Realm(configuration: config) let questions = realm.objects(Question.self)

Slide 48

Slide 48 text

[email protected] Update question let sortProperties = [SortDescriptor (keyPath: “isAnswered”, ascending: true), SortDescriptor(keyPath: "isFavorite", ascending: false), SortDescriptor(keyPath: “voteCount", ascending: false)] questions = realm?.objects(Question.self) .filter("status = true”) .sorted(by: sortProperties) notificationToken = questions.addNotificationBlock { [weak self] (changes: RealmCollectionChange) in guard let tableView = self?.questTableView else { return } switch changes { case .initial: DispatchQueue.main.async { tableView.reloadData() } break // case .update } } case .update(_, let deletions, let insertions, let modifications): DispatchQueue.main.async { 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() } break //

Slide 49

Slide 49 text

[email protected] ੿ܻ • ؘ੉ఠח ۄ੉࠳۽ ٣झ௼ী ૒੽ ੽Ӕೡ ࣻ ੓ח ഋక੄ ё୓۽ ੷੢ • Realm ݽ؛ ௿ېझח 1 ؀ 1, ׮ ؀ ׮ ҙ҅ܳ ݂௼۽ ੷੢ • ؊ ബਯ੸ੋ ؘ੉ఠ ܻ࠙ ߂ Ӓܛചܳ ਤ೧ ٣झ௼ী рױೞѱ ৈ۞ Realmਸ ੘ࢿೞҊ ҙܻ • ׮নೠ ਬझா੉झী ݏѱ ࢲ۽ ׮ܲ realmਸ ࢎਊ೧ࢲ ਬোࢿ ૐ؀ • ୽ج ೧Ѿ ߂ झః݃ ݃੉Ӓۨ੉࣌ਸ ਤ೧ ೙ਃद ੗୓ ۽૒ਸ ೒۞Ӓੋ оמ

Slide 50

Slide 50 text

[email protected] хࢎ೤פ׮! Eunjoo Im [email protected] https://realm.io/kr https://www.facebook.com/realmkr