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
3
3.9k
CQRSを学ぶついでにCloud FunctionsとFirestoreを連動させる時の小技も学ぶ
小技です。
hecateball
December 03, 2019
Tweet
Share
More Decks by hecateball
See All by hecateball
Vue 3の導入を急ピッチでやってみた
hecateball
3
590
決済システムを設計するときに忘れてはならないたった1つの大切なこと
hecateball
1
15k
Firebase Summit 2019 ~Webのはなし~
hecateball
0
110
Other Decks in Technology
See All in Technology
『GRANBLUE FANTASY Relink』キャラクターの魅力を支えるリグ・シミュレーション制作事例
cygames
0
120
20240911_New_Relicダッシュボード活用例
speakerdeckfk
0
110
言葉は感情の近似値である。その感情と言葉の誤差を最小化しよう ~コミュニケーションにおけるアナログ/デジタル変換の課題に立ち向かう~
nktamago
0
220
突撃! 隣のAmazon Bedrockユーザー 〜YouはどうしてAWSで?〜
minorun365
PRO
3
390
Technical Writing Meetup vol.35
soracom
PRO
2
120
OR学会2024秋_短期収益と将来のオフ方策評価性能を考慮したクーポン割当方策混合比の決定
recruitengineers
PRO
4
460
どこよりも遅めなWinActor Ver.7.5.0 新機能紹介
tamai_63
0
210
Segment Anything Model 2
tenten0727
3
700
LINEヤフーのフロントエンド組織・体制の紹介
lycorp_recruit_jp
1
1.2k
『GRANBLUE FANTASY Relink』ソフトウェアラスタライザによる実践的なオクルージョンカリング
cygames
0
170
リアルお遍路+SORACOM IoT
ozk009
1
140
AI活用したくてもできなかった不動産SaaSの今とこれから
nealle
0
330
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Adopting Sorbet at Scale
ufuk
73
8.9k
The Straight Up "How To Draw Better" Workshop
denniskardys
230
130k
What the flash - Photography Introduction
edds
67
11k
What's in a price? How to price your products and services
michaelherold
242
11k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
23
1.7k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
663
120k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
8.9k
Navigating Team Friction
lara
183
13k
GitHub's CSS Performance
jonrohan
1030
450k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
166
48k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.3k
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を適用すべきでないケースももちろんある ◦ ユーザ体験をよく考えて!