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
720
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
250
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
510
Realm World Tour Tokyo Recent Java Updates
zaki50
2
830
Realm World Tour - ErrorProne in Realm Java
zaki50
1
810
Other Decks in Technology
See All in Technology
「Docker Desktop不要の時代」は 来たのか?
ueponx
0
780
夫婦で子育てするための育児標準化
codmoninc
PRO
0
370
PagerDuty Tech Hub-鳴らすけれど、人は動かない
ezaki
0
180
Tofu-Controller lightning talk @ Containerday 2026
gionn
0
110
専門領域のAIをどう評価するか
bengo4com
2
220
ウォンテッドリーの最近のプロダクトと技術の紹介
stomk
0
100
Code for Security プロジェクト紹介 2026年10月
yu23ki14
0
110
実体験から学ぶ分析エージェントの開発と運⽤
recruitengineers
PRO
8
2.4k
AIがコードを書く時代に、エンジニアは何で自分の価値を証明するのか / In an era where AI writes code how do engineers prove their value
carta_engineering
3
1.1k
M5Stackで作る BLEマウス GPSログの世界
tomokusaba
0
430
DWH の限界突破! AI エージェント向け爆速リアルタイムデータ基盤 ClickHouse
jozono
1
480
go-sqletch
moznion
0
140
Featured
See All Featured
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1.1k
Balancing Empowerment & Direction
lara
6
1.3k
Bash Introduction
62gerente
615
220k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
380
How to train your dragon (web standard)
notwaldorf
96
6.9k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
630
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
630
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
A Modern Web Designer's Workflow
chriscoyier
699
190k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
Site-Speed That Sticks
csswizardry
13
1.6k
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]