CollectionGroup
を使う。
待ち焦がれたCollectionGroupがCloud Firestoreへやってきた。 - Qiita
Themeの中にcommentsというsub collectionみたいなやつがあったときに、
Theme A - comments
Theme B - comments
なときに、AからもBからも取りたい需要がある。
FirebaseFirestore.instance .collectionGroup('comments') .where('userId', isEqualTo: currentUserId) .orderBy('createdAt') .snapshots(),
.collectionGroup
を使う。
Operation was rejected because the system is not in a state required for the operation's execution. If performing a query, ensure it has been indexed via the Firebase console.
がうざい。
それは
https://console.firebase.google.com/u/0/project/プロジェクト名/firestore/indexes/single-field/manage
にある、 「自動インデックス設定」タブにある除外をいじろう。