简体   繁体   中英

Any solution to filter and order on two different document properties using Firestore

Issue

I am trying to filter and order on two different document properties using firestore. I am aware that in the documentation it says it is not possible. But I am confident there must be a solution perhaps on the client-side.

Understanding

Imagine you have a bunch of articles. In these articles, there are properties such as views and time . Say I wanted to sort so I would get the most viewed article within a week. How would I create this since Firestore does not allow such a thing? Any way to handle it on the client-side or any other solution?

I know this is invalid but perhaps there would be a way to make this work:

admin.firestore().collection("articles").where("time", "<=", mintime).orderBy("views", "desc")

But I am confident there must be a solution perhaps on the client-side.

The client side solution is to query for all possible documents, then sort them in the app instead of depending on Firestore to do that sorting for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM