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
CQRSを学ぶついでにCloud FunctionsとFirestoreを連動させる時の小技も学ぶ
Search
hecateball
December 03, 2019
Technology
4.4k
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
680
決済システムを設計するときに忘れてはならないたった1つの大切なこと
hecateball
1
15k
Firebase Summit 2019 ~Webのはなし~
hecateball
0
140
Other Decks in Technology
See All in Technology
ゴールデンパスは敷いただけでは道にならない ─ 企画部門のエンジニアが技術標準を事業価値に変えるまで
mhrtech
0
140
Road to SRE NEXTの今までとこれから
hiroyaonoe
0
300
依頼文化をやめる日 EM視点で語るPlatform EngineeringとInclusive SRE / Discussing Platform Engineering and Inclusive SRE from an EM's Perspective
shin1988
4
5.3k
End-to-Endで考える信頼性 —LINEアプリにおけるクライアント開発×SRE連携の実践
maruloop
4
4.1k
Kaggleで成長するために意識したこと
prgckwb
2
300
AI駆動開発におけるQAエンジニアの役割事例 〜AI駆動開発の現場から〜
kobayashiyorimitsu
0
490
ローカルLLMとLINE Botの組み合わせ その3 / LINE DC Generative AI Meetup #8
you
PRO
0
130
Genie Ontologyは銀の弾丸かを考える / Is Genie Ontology a Silver Bullet?
nttcom
0
240
関数型の考えを TypeScript に持ち込んで、テストしやすい純粋関数を増やす / Pure at the Core, Effects at the Edge: Bringing Functional Thinking into TypeScript
kaminashi
1
110
脱金融のフューチャー・デザイン / Future Design Beyond Finance
ks91
PRO
0
150
ゼロをイチにする仕事が終わったあと
smasato
0
330
誤解だらけの開発生産性 / Myths and Misconceptions about Developer Productivity
i35_267
1
230
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
234
18k
We Are The Robots
honzajavorek
0
270
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
190
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
200
The Spectacular Lies of Maps
axbom
PRO
1
850
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
390
Designing for Timeless Needs
cassininazir
1
320
Documentation Writing (for coders)
carmenintech
77
5.4k
The Curious Case for Waylosing
cassininazir
1
430
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
760
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
340
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を適用すべきでないケースももちろんある ◦ ユーザ体験をよく考えて!