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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
その Valkey 使いこなしていますか?
onk
PRO
5
1.5k
USB PDを使ってスマホを労わりたい
raspython3
0
180
DWH の限界突破! AI エージェント向け爆速リアルタイムデータ基盤 ClickHouse
jozono
1
480
PHPカンファレンス関西の招待状 / Invitation to PHP Conference Kansai
ykanoh
0
130
Code for Security プロジェクト紹介 2026年10月
yu23ki14
0
110
V8のArray.prototype.flatを最大約20倍速くするまでと、巨大OSSへの大規模コミットの道のり
riyaamemiya
0
290
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
1
580
スキマバイトという雇用形態は存在しないので、雇用期間1日のアルバイト契約を事業者とワーカーが結ぶ手続きを支えるのがタイミーなんです
akitoshiga
0
200
エンタメ企業のM&Aを支えるデータ基盤 ― 統合から店舗のリアルタイム分析まで / Data Engineering Summit 2026
genda
0
180
M5Stackで作る BLEマウス GPSログの世界
tomokusaba
0
430
コンテナ運用におけるネットワーク・コンテナコストの削減方法/How to Reduce Network and Container Costs in Container Operations
masakiokuda
1
230
自作バイナリを動かす「入口」8選
puhitaku
2
1.3k
Featured
See All Featured
A better future with KSS
kneath
240
18k
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
300
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Design in an AI World
tapps
1
350
Tell your own story through comics
letsgokoyo
1
1.1k
Done Done
chrislema
187
17k
We Are The Robots
honzajavorek
0
400
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
360
It's Worth the Effort
3n
188
29k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
Statistics for Hackers
jakevdp
799
230k
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]