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
API を Firebase Realtime Database に移行して気付いたこと
Search
syamaoka
August 28, 2017
Technology
1
790
API を Firebase Realtime Database に移行して気付いたこと
syamaoka
August 28, 2017
Tweet
Share
More Decks by syamaoka
See All by syamaoka
API を Firebase Realtime Database に移行して気付いたこと ver2
bpyamasinn
1
510
Other Decks in Technology
See All in Technology
AI時代の開発を加速する組織づくり - ブログでは書けなかったリアル
hiro8ma
1
240
HonoとJSXを使って管理画面をサクッと型安全に作ろう
diggymo
0
160
あなたの知らない Linuxカーネル脆弱性の世界
recruitengineers
PRO
3
130
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
5
43k
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
12
81k
Kubernetes self-healing of your workload
hwchiu
0
350
Node.js 2025: What's new and what's next
ruyadorno
0
980
私のMCPの使い方
tsubakimoto_s
0
120
初めてのDatabricks Apps開発
taka_aki
1
240
Sansan Engineering Unit 紹介資料
sansan33
PRO
1
3k
Introduction to Sansan Meishi Maker Development Engineer
sansan33
PRO
0
310
OpenTelemetry が拡げる Gemini CLI の可観測性
phaya72
2
1.7k
Featured
See All Featured
Faster Mobile Websites
deanohume
310
31k
Navigating Team Friction
lara
190
15k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
140
34k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
920
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Context Engineering - Making Every Token Count
addyosmani
7
290
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
Rails Girls Zürich Keynote
gr2m
95
14k
The Language of Interfaces
destraynor
162
25k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Transcript
API Λ Firebase Realtime Database ʹҠߦͯ͠ؾ͍ͨ͜ͱ 2017/08/28 syamaoka GCPUG Firebase
Realtime Database /meetup/1
ࣗݾհ ໊લɿ ࢁԬ ਅ (syamaoka) झຯɿ ɾ MMO RPG ɾ
PC : Tales Weaver ɾ Mobile : Lineage 2 Revolution ɾ MoBA : VainGlory ୲ɿ ɾ iOS, όοΫΤϯυ (API, Batch)
୲தαʔϏεͰꙍ ֵአͭͼ͚Ρ䱛ᚆ • Realtime Database • Remote Config • Firebase
Authentication • Analytics • App Indexing • Firebase Performance Monitoring
୲தαʔϏεͰꙍ ֵአͭͼ͚Ρ䱛ᚆ • Realtime Database <- ࠓ͜͜Λத৺ʹ͠·͢ ! • Remote
Config • Firebase Authentication • Analytics • App Indexing • Firebase Performance Monitoring
ΞδΣϯμ • API -> Firebase Realtime Database • ΞϓϦଆͷ࣮ •
ηΩϡϦςΟϧʔϧʹ͍ͭͯ
Firebase ʹٻΊ͍ͯΔ͜ͱ • API ࡞ͷܰݮ • ύϑΥʔϚϯενϡʔχϯά͔Βͷ٫ • ΦϑϥΠϯ࣌ͷσʔλͷѻ͍͢͞ʢॲཧͷ؆୯͞ʣ
API -> Firebase Realtime Database
Ұ൪ࠔͬͨʢࠓෆ҆ʣͷɺ ߹ੑ !
݁
ΞϓϦέʔγϣϯίʔυΛ৴͡ΔʢఘΊʣ Firebase RDB Ͱͳ͍ͨΊɺ֎෦Ωʔ੍͕ͳ͍ɻ ͦͷͨΊɺ݁߹͕ඞཁͳՕॴొ͢ΔࡍʹίʔυͰ֬ೝɻ εΩʔϚϨε(Ұ؏ੑ͕ͳ͍)Ͱɺ݁߹͖͔͢൱͔Λஅ͠ɺ ࠷దͳઃܭΛ͍ͯ͘͠ͷ͕ॏཁɻ ! ΤϯδχΞͷͷݟͤॴ
!
ιʔτͷಛ • ΩʔΛࢦఆͯ͠ঢॱͰऔಘ • ฦ٫͢Δσʔλͷॱ൪อূ͍ͯ͠ͳ͍
ιʔτͷಛ • ΩʔΛࢦఆͯ͠ঢॱͰऔಘ • ฦ٫͢Δσʔλͷॱ൪อূ͍ͯ͠ͳ͍
ฦ٫͢Δσʔλͷॱ൪อূ͍ͯ͠ͳ͍ ྫ͑ created_at Ͱιʔτ͠ɺ ࠷৽σʔλΛ 10 ݅औಘͨ࣌͠ɺ ฦ٫͞ΕΔσʔλ࠷৽σʔλͷ 10 ͕݅ͩɺ
ฦ٫͞ΕΔ JSON ͷฒͼॱอূ͞Ε͍ͯͳ͍
None
Q. ͭ·ΓΞϓϦଆͲ͏͢Ε͍͍ʁ A. ฦ٫͞ΕͨΛιʔτ͢͠ɻ
߱ॱʹ͢Δʹʁ • created_at Λ - ͷʹͯ͠ɺ߱ॱʹͳΔ key Λੜ https://stackoverflow.com/questions/34156996/firebase- data-desc-sorting-in-android/42572025#42572025
• શ݅औಘͯ͠ΞϓϦଆͰ߱ॱʹฒͼସ͑Δ • QueryLastTo Λͬͯ࠷ޙͷσʔλ͔Βऔಘ͢Δ
ϩδοΫॱʹ͢Δʹʁ ϩδοΫʹΑΔฒͼॱɺ Firebase Realtime Database ͚ͩͰ͍͠ɻ
ιʔτ༻ͷσʔλΛ࡞ { "articleOrders": { "articleId1": 1, "articleId2": 2 } }
ϝϦοτ • ࠷খݶͷࢀর • ΞϓϦͷมߋͳ͠ʹཪଆͰॱ൪Λมߋग़དྷΔ ※ articles ͷதʹ order Λ༻ҙͨ͠߹ɺarticles
શͯΛಡ ΈࠐΉඞཁ͕͋ΓɺύϑΥʔϚϯε͕ѱ͍ ❌
σϝϦοτ • ߋ৽ִ͕ؒ͘ग़དྷͳ͍ • ̍࣌ؒຖʹߋ৽ͱ͔Ͱ͋Εେৎ͕ͩɺ5ຖͱ͔ͩͱ ͖ͬͱݫ͍͠ • ܭࢉରͷσʔλྔʹݶք͕͋Δ
Cloud Function ͱ͍ ͚Α͏ !
Rule ʹ͍ͭͯ
Rule େମҎԼͷ̐ͭ • Read and Write • Type • Require
• index
ܕͷࢦఆํ๏ { "article": { "title": { ".validate": "newData.isString()" }, "visible":
{ ".validate": "newData.isBoolean()" } } }
ඞਢύϥϝʔλͷࢦఆํ๏ { "article": { ".validate": "newData.hasChildren(['title','visible'])" } }
Index ͷࢦఆํ๏ { "article": { ".indexOn": [ "title" ] }
}
γϛϡϨʔλ͕͍͢͝ศར !
Demo
͔͠͠ɺ͜ΕΛखೖྗͰ શ෦ཧ͢Δͷେม !
None
⚠ 8/28 ࣌ β ver
Demo
ઃఆϑΝΠϧ https://gist.github.com/bpyamasinn/ c1f62153f0bea8a499c111f4f30c8546
Index ͷઃఆ͚ͩগ͔͍ͬ͠ Index Path Ͱࢦఆ͠ͳͪ͘Ό͍͚ͳ͍ͨΊɺ Type ʹهࡌग़དྷͳ͍ͨΊɺδΣωϦΫεΛͬͯఆٛͨ͠ࡍʹ ៉ྷʹॻ͚ͳ͍෦͕ग़ͯ͘Δ !
Client Side Join
σʔλྫ { "articles" : { "hogeId" : { "title" :
"λΠτϧ", "category" : "categoryID_1" } }, "categories" : { "categoryID_1" : { "name": "ήʔϜ" } } }
ํ๏ RxSwift ͷ zip Λ༻͍ͯϚʔδ͢Δ
݁߹ͷྲྀΕ 1. articles ͱ categories Λฒྻʹऔಘ 2. RxSwift ͷΦϖϨʔλ zip
Λ༻͍ͯɺ྆ํͷσʔλΛऔಘ͢Δ 3. ྆σʔλΛ݁߹͢Δ
ΞϓϦଆͰͷιʔτߜΓࠐΈ ެࣜυΩϡϝϯτʹهࡌ͞Ε͍ͯΔ௨Γɺ ΫϥΠΞϯταΠυͰͷιʔτϑΟϧλϦϯάਪ͞Εͯ ͍ͳ͍ ❌
ΞϓϦଆͰॲཧग़དྷͳ͍ͷɺ όονͰσʔλΛ༻ҙ͢Δ !
࣍·ͨϦϦʔεޙʹൃද͠·͢ !