Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Realm Japan meetup Ueda
Search
zaki50
November 12, 2016
Technology
710
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
240
Android Studio 3.0 profilerハンズオン
zaki50
2
810
Realm Japan meetup #23_Java
zaki50
0
770
Realm Japan meetup #22_Java
zaki50
1
590
Realm World Tour Osaka Recent Java Updates
zaki50
0
500
Realm World Tour - ErrorProne in Realm Java
zaki50
2
500
Realm World Tour Tokyo Recent Java Updates
zaki50
2
820
Realm World Tour - ErrorProne in Realm Java
zaki50
1
800
Other Decks in Technology
See All in Technology
AI 時代のスタートアップエコシステ厶から考究する技術的負債との向き合い方
m3m0r7
PRO
3
2.3k
ユーザー価値を届け続けるためにウォンテッドリーが大切にしている文化
kotaminato
0
180
バイブコーディング時代のWebアプリ開発入門~Cloud Runで学ぶセキュアなビルドとデプロイ
waiwai2111
1
140
Vibe Coding で作ったプロダクトをどう安全に動かすか / How to Safely Run Products Built with Vibe Coding
glidenote
0
170
SREの視点で考えるSIEM活用術 〜AWS環境でのセキュリティ強化〜
cscengineer
PRO
0
110
作って終わりじゃないサーバーレス 〜9年運用する大規模EC物流API基盤の設計・運用のリアル〜
zozotech
PRO
0
170
AgentCore Runtime上にAgentic Coding基盤を構築・展開する際の設計ポイントと限界点 / Design considerations and limitations when building an agentic coding platform on AgentCore Runtime
har1101
5
320
技術的負債から考える、AI時代のエンジニアリング投資 — ビズリーチの技術的負債と向き合った経験から、変更し続けられるソフトウェアを考える/ technical-debt-con2026
visional_engineering_and_design
4
3.2k
JSONataとAWS Step Functionsで目指すRuntimelessな世界
mu7889yoon
0
190
アクセスキーこわい やめかたと漏らさない工夫
sassssan68
1
430
AIエージェントの自己改善をどう設計するか / How to Design Self-Improvement for AI Agents
22mi
25
16k
今話題のAI「Jev」って何? 宇宙最速で学ぶ会
minorun365
PRO
29
16k
Featured
See All Featured
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Odyssey Design
rkendrick25
PRO
2
810
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
460
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
460
Bash Introduction
62gerente
615
220k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1k
The Cost Of JavaScript in 2023
addyosmani
55
10k
From π to Pie charts
rasagy
1
370
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
GraphQLとの向き合い方2022年版
quramy
50
15k
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]