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
CQRSを学ぶついでにCloud FunctionsとFirestoreを連動させる時の小技も学ぶ
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
hecateball
December 03, 2019
Technology
4.5k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CQRSを学ぶついでにCloud FunctionsとFirestoreを連動させる時の小技も学ぶ
小技です。
hecateball
December 03, 2019
More Decks by hecateball
See All by hecateball
Vue 3の導入を急ピッチでやってみた
hecateball
3
690
決済システムを設計するときに忘れてはならないたった1つの大切なこと
hecateball
1
15k
Firebase Summit 2019 ~Webのはなし~
hecateball
0
150
Other Decks in Technology
See All in Technology
IoTデバイスを繋げるプロトコルMatterをAndroidで使用する方法
harutiro
0
120
並行性の問題を防げ!実践トランザクション入門
occhi
0
260
[2026 Oracle Technical Deep Dive] OCI AI Resilience -OCIのセキュリティ対策機能をきちんと使いこなす- (2026年9月17日開催)
oracle4engineer
PRO
0
130
SDDの運用にめげずに向き合った話
sansantech
PRO
0
130
【データ横丁主催】AI Agentがコンテキストを使って仕事をした後、何が残るのか― 組織の経験を次の判断に引き継ぐ「Agent Memory」
shisyu_gaku
2
330
営業オントロジーの作り方と、エージェントからの辿り方 ── ナレッジワークの現場から
kworkdev
PRO
1
270
The seven pitfalls of AI (revised version)
ufried
0
260
インバスケット試験対策アプリを 作って見えたAIエージェント構築 ナレッジ2選
shichijoyuhi
1
130
DAMOS - The Smart Cruise Control for RAM
ennael
PRO
1
130
転んだ話が背中を預ける理由になる / A_story_about_falling_down_gives_you_a_reason_to_watch_each_other_s_backs.pdf
pauli
3
220
自主式軟體工廠
philipz
0
220
スキルを作る、その前に!複数人で使われるスキルを 作るためのプロセス
junkifurukawa
2
310
Featured
See All Featured
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
440
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Git: the NoSQL Database
bkeepers
PRO
433
67k
HDC tutorial
michielstock
2
940
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
710
The SEO Collaboration Effect
kristinabergwall1
1
590
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
470
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
540
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Mind Mapping
helmedeiros
1
390
So, you think you're a good person
axbom
PRO
2
2.2k
Building Adaptive Systems
keathley
44
3.2k
Transcript
CQRSを学ぶついでに Cloud Functionsと Firestoreを連動させる時の 小技も学ぶ Firebase Meetup #15
自己紹介 Yuuki Fukuda 株式会社ディー・エヌ・エー オープンプラットフォーム事業部 -- Twitter: @hecateball
Disclaimer • このスライドに記載されている内容は発表者個人の知見に基づくものであり、所属 する組織の公式の見解ではありません • また、情報の正確性を保証するものではありません。このスライドの内容を利用し たいかなる結果に関しても責任を負いかねます • 資料は後ほど公開するので、記憶・記録する必要はありません
今日話す内容 • CQRSって何? • FirebaseでCQRSするモチベーション • Functionsを使ったCQRSの実装 • FirestoreとFunctionsを併用する際のポイント
Command Query Responsibility Segregation (コマンドクエリ責務分離)
一般的なデータ読み書き
Read/Writeの関心事 Read Write • データ検索の効率化・高速化 • 結合・集計処理 • データの整合性の維持 •
アトミックオペレーション • 排他制御
CQRS(コマンドクエリ責務分離)とは
なぜFirebaseでCQRS? • Read用/Write用でモデルを分離できることの恩恵が非常に大 きい • Writeモデルを書き込み操作ログとして利用できる
Functions+Firestoreで実装する際のポイント
None
{ “user”: …, “createdAt”: ... } (ツイート) favorite_countを 1増やす
イベント:ビジネスロジック = 1 : n
よい イマイチ
Functionsのディレクトリ構成と Firestoreのコレクション構成を 一致させる小技
その他の小技 • Callable Functionsは使わない • updateトリガーを注意深く避ける • 「似て非なるイベント」はコレクションを分ける
ご清聴ありがとうございました • 主役はバックグラウンド関数 • リアクティブシステムを搭載したフロントエンド技術と相性が良 い • CQRSを適用すべきでないケースももちろんある ◦ ユーザ体験をよく考えて!