firestore REST order by 2 fields ( composite query )

278 Views Asked by At

the firestore REST documentation doesn't mention info about compound queries https://firebase.google.com/docs/firestore/reference/rest/v1/projects.databases.documents/list

  1. How can I order by 2 fields when querying a list of documents ? ( for example, I want the student documents to be ordered by the student school ID then by the student average score )

  2. do I need to manually generate the composite index ( the sdks provide you with a url to generate the required composite index )?

Thanks

1

There are 1 best solutions below

0
On

somehow I missed it in the docs, here is the syntax for composite queries, simply separate the fields by a comma

https://firebase.google.com/docs/firestore/reference/rest/v1/projects.databases.documents/listDocuments

cities?orderBy=likeCount, likeAverage