Realm Mobile Platform overview and demo

1fa9cb8c7997c8c4d3d251fb5e41f749?s=47 Realm
June 12, 2017

Realm Mobile Platform overview and demo

Realm Mobile Platform overview and demo
Realm World Tour Seoul: June 8th 2017

1fa9cb8c7997c8c4d3d251fb5e41f749?s=128

Realm

June 12, 2017
Tweet

Transcript

  1. 1.
  2. 2.
  3. 16.

    ӝઓ ؘ੉ఠ ాन 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 eunjoo.im@realm.io
  4. 17.

    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 eunjoo.im@realm.io
  5. 18.

    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 eunjoo.im@realm.io
  6. 21.

    ؊ ݆਷ ࢲߡ ӝמ • Realm Database SDK • ੋૐ

    • ঐഐചػ ੹࣠ • पदр زӝച • ୽ج ೧Ѿ • ࣻز ߔস • ࢲߡஏ ੉߮౟ ೩ٜ݂ • ݽפఠ݂ • ؘ੉ఠ ੽Ӕ • Ҋоਊࢿ • ۽٘ ߖ۠य • ࣻಣ झாੌ݂ • োࣘ ߔস eunjoo.im@realm.io PE EE DE
  7. 25.

    eunjoo.im@realm.io زӝ 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)
  8. 26.

    eunjoo.im@realm.io زӝ Realm ਬഋ ҕਊ Realm ѐੋ Realm • ݽٚ

    ࢎਊ੗о ࠅ ࣻ ੓਺ • ࢎਊ੗ח ੍ӝ ӂೠ݅ ࠗৈ • ౠ੿ ࢎਊ੗о ࣗਬ੗ • ׮ܲ ࢎਊ੗ী ӂೠ ࠗৈ ҕਬ Realm
  9. 27.

    eunjoo.im@realm.io ࣳೝށ दաܻয় ઁಿ ݾ۾ ࣳೝ ܻझ౟ ੢߄ҳפ ҕਊ Realm

    ѐੋ Realm • ݽٚ ࢎਊ੗о ࠅ ࣻ ੓਺ • ࢎਊ੗ח ੍ӝ ӂೠ݅ ࠗৈ • ౠ੿ ࢎਊ੗о ࣗਬ੗ • ׮ܲ ࢎਊ੗ী ӂೠ ࠗৈ ҕਬ Realm
  10. 28.

    eunjoo.im@realm.io ҕਊ Realm Realm য়࠳ં౟ ࢲߡ userA: ੍ӝ ӂೠ userB:

    ੍ӝ ӂೠ /productCatalog /productCatalog ؘ੉ఠ ಹद /productCatalog ؘ੉ఠ ಹद /productCatalog ؘ੉ఠ ಹद userC: ੍ӝ ӂೠ
  11. 29.

    eunjoo.im@realm.io ѐੋ Realm /userA/cart Realm য়࠳ં౟ ࢲߡ userA: য٘޹ ӂೠ

    userB: য٘޹ ӂೠ নߑೱ زӝച /userB/cart /userA/cart /userB/cart নߑೱ زӝച
  12. 30.

    eunjoo.im@realm.io ѐੋ-ҕਬ Realm /userA/shoppingList /userA/shoppingList Realm য়࠳ં౟ ࢲߡ নߑೱ زӝച

    /userA/shoppingList userA: য٘޹ ӂೠ userB: ੍ӝ/ॳӝ ӂೠ নߑೱ زӝച
  13. 34.

    eunjoo.im@realm.io 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: ҙܻ ӂೠ
  14. 36.

    Function য়࠳ં౟ ࢲߡ੄ Ӗ۽ߥ ܻझ׬ API۽ ഐ୹غҊ changeEvent ё୓ܳ ੹׳ೞח

    Node.js ೣࣻ eunjoo.im@realm.io Realm FunctionsBeta झ௼݀౟ ௑ࣛ ۽Ӓ ܻझ׬ೡ Realm प೯/੷੢/࢏ઁ
  15. 39.
  16. 41.

    eunjoo.im@realm.io 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
  17. 42.

    eunjoo.im@realm.io 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) }); } });
  18. 45.

    eunjoo.im@realm.io 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<User>() 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
  19. 46.

    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 } eunjoo.im@realm.io 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 }
  20. 47.

    eunjoo.im@realm.io 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)
  21. 48.

    eunjoo.im@realm.io 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 //
  22. 49.

    eunjoo.im@realm.io ੿ܻ • ؘ੉ఠח ۄ੉࠳۽ ٣झ௼ী ૒੽ ੽Ӕೡ ࣻ ੓ח

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