万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

  • ・資産運用おすすめ
    10万円は1000円くらい利益
    資産運用ブログ アセマネ
    • ・寄付お願いします
      YENTEN:YYzNPzdsZWqr5THWAdMrKDj7GT8ietDc2W
      BitZenny:ZfpUbVya8MWQkjjGJMjA7P9pPkqaLnwPWH
      c0ban:8KG95GXdEquNpPW8xJAJf7nn5kbimQ5wj1
      Skycoin:KMqcn7x8REwwzMHPi9fV9fbNwdofYAWKRo

    サブコレクションのみだけを取得したい時

    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

    にある、 「自動インデックス設定」タブにある除外をいじろう。

    f:id:shinriyo:20210606130013p:plain