How to query one field then order by another one in Firebase cloud Firestore?

前端 未结 6 973
粉色の甜心
粉色の甜心 2021-02-13 04:14

I\'m struggling to make a (not so) complex query in firebase cloud firestore.

I simply need to get all docs where the id field ==

6条回答
  •  执笔经年
    2021-02-13 04:19

    You can do this by creating an Index in the firestore.

    The first field of the index should be the equality field and the second field of the index should be the order by field.

    Given your problem, you would need the following index:

    first field: postId, 'asc'
    second field: date, 'asc'
    

提交回复
热议问题