Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Realm Japan meetup Ueda
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
zaki50
November 12, 2016
Technology
700
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Realm Japan meetup Ueda
zaki50
November 12, 2016
More Decks by zaki50
See All by zaki50
I/O Extended 2018 @Tokyo Android1
zaki50
3
1.3k
簡単高速なDIライブラリToothpick
zaki50
1
230
Android Studio 3.0 profilerハンズオン
zaki50
2
800
Realm Japan meetup #23_Java
zaki50
0
760
Realm Japan meetup #22_Java
zaki50
1
570
Realm World Tour Osaka Recent Java Updates
zaki50
0
490
Realm World Tour - ErrorProne in Realm Java
zaki50
2
500
Realm World Tour Tokyo Recent Java Updates
zaki50
2
810
Realm World Tour - ErrorProne in Realm Java
zaki50
1
790
Other Decks in Technology
See All in Technology
アジャイルな経理と Claude Code と経営の未来
kawaguti
PRO
3
170
アンオフィシャルな、オフィシャルからのお願い
wyamazak_devrel
0
140
Agile and AI Redmine Japan 2026
hiranabe
3
350
Chainlitで作るお手軽チャットUI
ynt0485
0
280
いまさら聞けない「仕様駆動開発入門」 〜AI活用時代の開発プロセスを考える〜
findy_eventslides
2
160
秘密度ラベル初心者が第1歩でつまづかないための「設計・運用」ポイント
seafay
PRO
1
360
LayerX コーポレートエンジニアリング室におけるサプライチェーンセキュリティへの取り組み / Supply Chain Security at LayerX Corporate Engineering
yuyatakeyama
2
700
人材育成分科会.pdf
_awache
4
300
iOS アプリの「これって不具合ですか?」を AI に調べてもらう
miichan
0
110
iAEONの段階的リアーキテクト戦略 / iAEON's_Gradual_Re-architecture_Strategy
aeonpeople
0
230
Kiro Ambassador を目指す話
k_adachi_01
0
110
AIチャット検索改善の3週間
kworkdev
PRO
2
150
Featured
See All Featured
Ruling the World: When Life Gets Gamed
codingconduct
0
260
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
350
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
71
40k
Being A Developer After 40
akosma
91
590k
BBQ
matthewcrist
89
10k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
200
Prompt Engineering for Job Search
mfonobong
0
350
GraphQLとの向き合い方2022年版
quramy
50
15k
We Are The Robots
honzajavorek
0
250
A Soul's Torment
seathinner
6
3k
Odyssey Design
rkendrick25
PRO
2
700
Transcript
Realm meetup ্ా
[email protected]
#realm_jp
[email protected]
Makoto Yamazaki Realm Inc. / uPhyca Inc.
[email protected]
What is Realm?
[email protected]
ٌغ؎ٕرغ؎أ㼔欽ח倜׃ֻ⡲ر٦ةك٦أ 0CKFDUJWF$䎃剢։ +BWB䎃剢։ 4XJGU䎃剢։ ٌغ؎ٕ欽鷿ח剑黝⻉ׁגְ 鹼䒀ٗ٦س
ئٗ؝ؾ٦ ط؎ذ؍ـ٥ؙٔٝ Realm
[email protected]
Realm ˖ ؙٗأفٓحزؿؓ٦ي ˖ J04"OESPJE ˖ +BWB 4XJGU 0CKFDUJWF$ $
+BWB4DSJQU ˖ ؔ٦فٝا٦أ ˖ 杝荈%#ؒٝآٝ42-JUF⢪גְזְ
[email protected]
Realmͷಛ 넝鸞ז⹛⡲ 农〾⻉垥彊鄲⪒ 湫䠬涸דءٝفٕז"1* ♨㻝ז؟ه٦ز傈劤铂0,
[email protected]
public class Article extends RealmObject { @PrimaryKey private int id;
@Required private String title; private String contents; private Date creationDate; private Date modificationDate; private User user; private RealmList<Comment> comments; // getter, setter } Ϟσϧʢςʔϒϧʣఆٛ
[email protected]
class Article: Object { dynamic var id: Int = 0
dynamic var title: String = "" dynamic var contents: String = "" dynamic var creationDate: NSDate = NSDate() dynamic var modificationDate: NSDate = NSDate() dynamic var user: User? = nil let comments = List<Comment>() } Ϟσϧʢςʔϒϧʣఆٛ (iOS)
[email protected]
public class Article extends RealmObject { @PrimaryKey private int id;
@Required private String title; private String contents; private Date creationDate; private Date modificationDate; private User user; private RealmList<Comment> comments; // getter, setter } Ϟσϧʢςʔϒϧʣఆٛ RealmObjectΫϥεΛܧঝ
[email protected]
public class Article extends RealmObject { @PrimaryKey private int id;
@Required private String title; private String contents; private Date creationDate; private Date modificationDate; private User user; private RealmList<Comment> comments; // getter, setter } Ϟσϧʢςʔϒϧʣఆٛ ΧϥϜͱσʔλܕ
[email protected]
public class Article extends RealmObject { @PrimaryKey private int id;
@Required private String title; private String contents; private Date creationDate; private Date modificationDate; private User user; private RealmList<Comment> comments; // getter, setter } Ϟσϧʢςʔϒϧʣఆٛ nullͷՄʗෆՄ
[email protected]
public class Article extends RealmObject { @PrimaryKey private int id;
@Required private String title; private String contents; private Date creationDate; private Date modificationDate; private User user; private RealmList<Comment> comments; // getter, setter } Ϟσϧʢςʔϒϧʣఆٛ ̍ର̍ͷؔ࿈
[email protected]
public class Article extends RealmObject { @PrimaryKey private int id;
@Required private String title; private String contents; private Date creationDate; private Date modificationDate; private User user; private RealmList<Comment> comments; // getter, setter } Ϟσϧʢςʔϒϧʣఆٛ ̍ରଟͷؔ࿈
[email protected]
public final class RealmList<E extends RealmModel> extends java.util.AbstractList<E> implements io.realm.OrderedRealmCollection<E>
{ .... } Ϟσϧʢςʔϒϧʣఆٛ RealmListΫϥε
[email protected]
byte/Byte short/Short int/Integer long/Long boolean/Boolean float/Float double/Double String Date byte[]
モデルクラス RealmList<モデルクラス> Ϟσϧʢςʔϒϧʣఆٛ ΧϥϜʹ༻Ͱ͖Δܕ
[email protected]
Article article = new Article(); article.setId(1); article.setTitle("Realm meetup"); Realm
realm = Realm.getDefaultInstance(); try { realm.executeTransaction(realm -> { realm.insert(article); }); } finally { realm.close(); } σʔλͷอଘ
[email protected]
Article article = new Article(); article.setId(1); article.setTitle("Realm meetup"); Realm
realm = Realm.getDefaultInstance(); try { realm.executeTransaction(realm -> { realm.insert(person); }); } finally { realm.close(); } σʔλͷอଘ ϞσϧΦϒδΣΫτͷ࡞
[email protected]
Article article = new Article(); article.setId(1); article.setTitle("Realm meetup"); Realm
realm = Realm.getDefaultInstance(); try { realm.executeTransaction(realm -> { realm.insert(person); }); } finally { realm.close(); } σʔλͷอଘ RealmΠϯελϯεͷऔಘ
[email protected]
Article article = new Article(); article.setId(1); article.setTitle("Realm meetup"); Realm
realm = Realm.getDefaultInstance(); try { realm.executeTransaction(realm -> { realm.insert(person); }); } finally { realm.close(); } σʔλͷอଘ ςʔϒϧૠೖ
[email protected]
Realm realm = Realm.getDefaultInstance(); try { RealmResults<Article> articles = realm.where(Article.class)
.beginsWith("title", "Realm") .findAllSorted("creationDate", Sort.DESCENDING); } finally { realm.close(); } ΫΤϦ
[email protected]
Realm realm = Realm.getDefaultInstance(); try { RealmResults<Article> articles = realm.where(Article.class)
.beginsWith("title", "Realm") .findAllSorted("creationDate", Sort.DESCENDING); } finally { realm.close(); } ΫΤϦ RealmΠϯελϯεͷऔಘ
[email protected]
Realm realm = Realm.getDefaultInstance(); try { RealmResults<Article> articles = realm.where(Article.class)
.beginsWith("title", "Realm") .findAllSorted("creationDate", Sort.DESCENDING); } finally { realm.close(); } ΫΤϦ ݅ͷࢦఆͱ݁Ռͷऔಘ
[email protected]
Realm realm = Realm.getDefaultInstance(); try { RealmResults<Article> articles = realm.where(Article.class)
.equalTo("user.name", "Tim") .lessThan("user.age", 30) .findAllSorted("creationDate", Sort.DESCENDING); } finally { realm.close(); } ϦϯΫΫΤϦ
[email protected]
Realm realm = Realm.getDefaultInstance(); try { RealmResults<Article> articles = realm.where(Article.class)
.contains("comments.message", "Ueda") .contains("comments.message", "meetup") .findAllSorted("creationDate", Sort.DESCENDING); } finally { realm.close(); } ϦϯΫΫΤϦ ҙʂ
[email protected]
realm.where(Foo.class).equalTo(FooFields.AGE, 20); realm.where(Foo.class).equalTo("age", 20) http://bit.ly/RealmField realm.where(Foo::class.java).equalTo(Foo::age.name, 20); KotlinͷਓݩʑҎԼͷΑ͏ʹॻ͚ΔͷͰෆཁͰ͢ Realm Field
Names Helper
[email protected]
ΫΤϦϝιου isNull/isNotNull isEmpty/isNotEmpty equalTo/notEqualTo greaterThan greaterThanOrEqualTo lessThan lessThanOrEqualTo between contains
beginsWith endsWith in and or not beginGroup endGroup
[email protected]
ूܭϝιου sum average min max maximumDate minimumDate count
[email protected]
Realm realm = Realm.getDefaultInstance(); try { RealmResults<Article> articles = ...;
Article article = articles.first(); article.isManaged(); // true Log.d("realm", article.getTitle()); Log.d("realm", article.getUser().getName()); Log.d("realm", article.getComments().get(0).getMessage()); } finally { realm.close(); } σʔλͷಡΈग़͠
[email protected]
RealmResults<Article> articles = ...; articles.addChangeListener(results -> { // ArticleΫϥεʹ͍ͭͯมߋɾՃɾআͷࡍʹݺΕΔ });
Article article = articles.first(); article.addChangeListener(obj -> { // ArticleΫϥεʹ͍ͭͯมߋɾՃɾআͷࡍʹݺΕΔ }); มߋ௨
[email protected]
࣮ࡍͷ͍ํ
[email protected]
࣮ࡍͷ͍ํ Activityฤ public class ArticleActivity extends AppCompatActivity { private Realm
realm; private Article article; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_article); int id = getIntent().getIntExtra("id", 0); realm = Realm.getDefaultInstance(); article = realm.where(Article.class).equalTo("id", id); } @Override public void onDestroy() { super.onDestroy(); realm.close(); } }
[email protected]
࣮ࡍͷ͍ํ Fragmentฤ public class ArticleFragment extends Fragment { private Realm
realm; private Article article; @Override public View onCreateView(...) { super.onCreateView(...); realm = Realm.getDefaultInstance(); int id = getIntent().getIntExtra("id", 0); article = realm.where(Article.class).equalTo("id", id); // Viewの作成 } @Override public void onDestroyView() { super.onDestroyView(); realm.close(); } }
[email protected]
࣮ࡍͷ͍ํ ඇLooperεϨουฤ public class MyThread extends Thread { @Override public
void run() { while(true) { // なんらかの処理 //結果を保存 Realm realm = Realm.getDefaultInstance(); try { realm.executeTransaction(realm -> { realm.insert(person); }); } finally { realm.close(); } } } }
[email protected]
࣮ࡍͷ͍ํ ඇLooperεϨουฤ public class MyThread extends Thread { @Override public
void run() { Realm realm = Realm.getDefaultInstance(); try { RealmResults<Article> articles = ...; while(true) { realm.waitForChange(); //articlesを読み出して必要な処理を実行 } } finally { realm.close(); } } }
[email protected]
public class MyApplication extends Application { @Override public void onCreate()
{ super.onCreate(); Realm.init(this); } } શମͷॳظԽ
[email protected]
ॏཁ֓೦
[email protected]
unmanaged/managed Article unmanagedArticle = new Article(); unmanagedArticle.isManaged(); // false unmanagedArticle.setTitle("meetup");
// OK RealmResults<Article> articles = ...; final Article managedArticle = articles.first(); managedArticle.isManaged(); // true managedArticle.setTitle("meetup"); // τϥϯβΫγϣϯΤϥʔ realm.executeTransaction(realm -> { managedArticle.setTitle("meetup"); // OK });
[email protected]
εϨουͷѻ͍ RealmΠϯελϯεͱ͔ͦ͜Βऔಘͨ͠ϥΠϒͳΦϒδΣΫτ εϨουؒͰͷड͚͠Λߦ͍͚ͬͯͳ͍ʂʂ
[email protected]
҉߸Խ
[email protected]
byte[] key = new byte[64]; new SecureRandom().nextBytes(key); final RealmConfiguration config
= new RealmConfiguration.Builder() .encryptionKey(key) .build(); final Realm realm = Realm.getInstance(config); ҉߸Խ
[email protected]
byte[] key = new byte[64]; new SecureRandom().nextBytes(key); final RealmConfiguration config
= new RealmConfiguration.Builder() .encryptionKey(key) .build(); final Realm realm = Realm.getInstance(config); ҉߸Խ 伴64όΠτ
[email protected]
byte[] key = new byte[64]; new SecureRandom().nextBytes(key); final RealmConfiguration config
= new RealmConfiguration.Builder() .encryptionKey(key) .build(); final Realm realm = Realm.getInstance(config); ҉߸Խ 伴ͷੜͷҰྫ
[email protected]
byte[] key = new byte[64]; new SecureRandom().nextBytes(key); final RealmConfiguration config
= new RealmConfiguration.Builder() .encryptionKey(key) .build(); final Realm realm = Realm.getInstance(config); ҉߸Խ 伴Ληοτͨ͠ઃఆใͷ࡞
[email protected]
byte[] key = new byte[64]; new SecureRandom().nextBytes(key); final RealmConfiguration config
= new RealmConfiguration.Builder() .encryptionKey(key) .build(); final Realm realm = Realm.getInstance(config); ҉߸Խ RealmΠϯελϯεͷऔಘ
[email protected]
˖ إٝءذ؍ـז䞔㜠ך⥂㶷 խ⦐➂䞔㜠ծ،ؕؐٝزز٦ؙٝזו ˖ 衼⡲埄זוד⥂隊ׁر٦ة ҉߸Խ
[email protected]
Realm Mobile Platform
[email protected]
[email protected]
What is Realm Mobile Platform?
[email protected]
Realm Mobile Database ˖ 42-JUFך➿剏הזٌغ؎ٕرغ؎أ㼔欽ך ر٦ةك٦أ ˖ ؙٗأفٓحزؿؓ٦ي ˖ J04"OESPJE
˖ +BWB 4XJGU 0CKFDUJWF$ $ +BWB4DSJQU ˖ ؔ٦فٝا٦أ
[email protected]
Realm Mobile Platform
[email protected]
Realm Mobile Platform Realm Mobile Database
[email protected]
Realm Mobile Platform Realm Mobile Database Data Sync ٔ،ٕة؎يず劍
[email protected]
Realm Mobile Platform Realm Mobile Database Data Sync User Identify
ٔ،ٕة؎يず劍 ِ٦ؠ٦陎ⴽ
[email protected]
Realm Mobile Platform Realm Mobile Database Data Sync Access Control
User Identify ٔ،ٕة؎يず劍 ِ٦ؠ٦陎ⴽ ر٦ةⰟ剣
[email protected]
Realm Mobile Platform Realm Mobile Database Data Sync Access Control
User Identify Event Handling ٔ،ٕة؎يず劍 ِ٦ؠ٦陎ⴽ ر٦ةⰟ剣 ؽآطأٗآحؙ
[email protected]
Realm Mobile Platform Realm Mobile Database
[email protected]
Demo
[email protected]
ͬͯΈΔ
[email protected]
ηοτΞοϓ
[email protected]
Realm Object ServerΛىಈ͢Δ
[email protected]
AdminΞΧϯτΛ࡞Δ
[email protected]
ηοτΞοϓ
[email protected]
ηοτΞοϓ
[email protected]
μογϡϘʔυ
[email protected]
μογϡϘʔυ
[email protected]
Object Server্ͷσʔλΛݟΔ
[email protected]
Realm Browser
[email protected]
جຊతͳ͍ํ
[email protected]
ΞΫηετʔΫϯʢmacOSʣ
[email protected]
ΞΫηετʔΫϯʢCentOSʣ # cd /etc/realm/ # ls admin_token.base64 configuration.yml token- signature.key
token-signature.pub # cat admin_token.base64 ewoJImlkZW50a...
[email protected]
جຊతͳ͍ํ(Android) ηοτΞοϓ realm { syncEnabled = true } appͷbuild.gradeʹ
[email protected]
جຊతͳ͍ํ(Android) ೝূ Credentials creds = Credentials.usernamePassword(username, password, true); User.loginAsync(creds, "https://realm.example.com:9443/auth",
new User.Callback() { @Override public void onSuccess(User user) { // ログイン成功時の処理 } @Override public void onError(ObjectServerError error) { // エラー処理 } } );
[email protected]
جຊతͳ͍ํ(Android) RealmΠϯελϯεͷऔಘ // ユーザーとURLから設定を作成 SyncConfiguration config = new SyncConfiguration.Builder(user, "realm://realm.example.com/~/userRealm").build();
// 同期されるRealm Realm realm = Realm.getInstance(config);
[email protected]
جຊతͳ͍ํ(iOS) User.authenticate(with: Credential.usernamePassword(username: "username", password: "password", actions: []), server: URL(string:
"http://128.199.141.202:9080")!, onCompletion: { user, error in guard let user = user else { fatalError(String(describing: error)) } let configuration = Realm.Configuration( syncConfiguration: (user, URL(string: "realm://128.199.141.202:9080/~/realmtasks")!) ) self.realm = try! Realm(configuration: configuration) })
[email protected]
FacebookϩάΠϯ
[email protected]
FacebookϩάΠϯ facebookAuth = new FacebookAuth(loginButton) { @Override public void onRegistrationComplete(LoginResult
loginResult) { SyncCredentials credentials = SyncCredentials.facebook( loginResult.getAccessToken().getToken()); SyncUser.loginAsync(credentials, AUTH_URL, LoginActivity.this); } };
[email protected]
FacebookϩάΠϯ developers.facebook.com/docs/facebook-login/ android
[email protected]
Typical Application Data Flow Native object JSON Native object SQL
Native object JSON Native object SQLite/CoreData SQLite/CoreData
[email protected]
w/ Realm Mobile Platform
[email protected]
Data Sync ر٦ةず劍
[email protected]
User Identify ر٦ةず劍 ِ٦ؠ٦陎ⴽ
[email protected]
Access Control ر٦ةず劍 ِ٦ؠ٦陎ⴽ ،ؙإأ؝ٝزٗ٦ٕ
[email protected]
Event Handling ؎كٝزعٝسؚٔٝ
[email protected]
ΠϕϯτϋϯυϦϯά var Realm = require('realm'); var filter_callback = function(realm_name) {
... }; var change_notification_callback = function(realm_name, realm) { var channels = realm.objects('Channel'); for (var i = 0; i < channels.length; ++i) { var channel = channels[i]; ... } }; Realm.setGlobalSyncListener(local_root_dir, server_base_url, access_token, filter_callback, change_notification_callback);
[email protected]
[email protected]
Realm Mobile Platform ˖ .PCJMF%BUBCBTF ˖ 倯ぢךر٦ةず劍 ˖ ٔ،ٕة؎ي ˖
ء٦يٖأ ˖ ؝ٝؿؙٔزך荈⹛鍑寸 ˖ ِ٦ؠ٦陎ⴽ ˖ ؎كٝزعٝسؚٔٝ • αʔόʔϓογϡ • σʔλڞ༗ • ΞΫηείϯτϩʔϧ
[email protected]
ίϯϑϦΫτͷղܾ • جຊޙউͪ • ಉ͡ΞΠςϜʹผͷมߋΛՃ͑ͨ߹ɺޙʹىͬͨ͜มߋ͕࠾༻ ͞Ε·͢ɻ • ಉ͡ΠϯσοΫεͷૠೖ࣌ؒॱʹͳΔ • আͯ͢ʹউͭ
• ͋ΔΞΠςϜ͕আ͞ΕͯɺผͷσόΠεͰಉ͡ΞΠςϜΛมߋ ͨ͠ɺͱ͍͏߹ɺআ͚͕ͩى͜Γ·͢ɻ
[email protected]
Demo github.com/realm/RealmTasks
[email protected]
Recent Updates
[email protected]
Recent Updates • Realm Objective-C/Swift 2.0.3 • Realm Java 2.2.0
• Realm React Native 0.14.0 • Realm Xamarin 0.78
[email protected]
Where to find us • $ Realm Japan User Group:
facebook.com/groups/realmjp • $ Twitter: twitter.com/realmJapan • GitHub: github.com/realm • $ StackOverflow: ja.stackoverflow.com/questions/tagged/realm • $ Email:
[email protected]
• $ Slack: slack.realm.io/
[email protected]
Realm Japan User Group Facebook
[email protected]
Support Chat Slack http://slack.realm.io/
[email protected]
Ξϯέʔτ http://bit.ly/RealmJP_Ueda
[email protected]
Questions? Makoto Yamazaki
[email protected]
www.realm.io/jp @zaki50
[email protected]