0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Firestoreで複数の並び替え

Posted at

取得したデータをRDBのように並び替えを複数で行いたいです。
ただこんな感じに書くと、記述内容は間違っていなさそうですが

return FirebaseFirestore.instance
      .collection('users')
      .orderBy('id')
      .orderBy('age')
      .startAt([value])
      .snapshots();

これだと以下のエラーになります。

Status{code=FAILED_PRECONDITION, description=The query requires an index.

orderByを2つ使用する場合はインデックスを貼る必要があります。
Cloud Firestoreで登録します。
エラー分の続きのURLから登録することもできます。(こちらのほが簡単)
ビルドの時間は少しかかります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?