Order By A Number Field Where A Timestamp Is On A Given Date In Cloud Firestore?
In my Firestore database I have some documents in a collection that look like this: { name: 'Item 1', count: 2, timestamp: January 29, 2018 at 3:43:12 PM UTC-8 } I'm trying
Solution 1:
As mentioned in the comments, Cloud Firestore does not support using more than a single field in range filters and/or order by clauses.
Given the nature of your query though, it is relatively simple to change it to an equality filter (today's date) and order by clause (count). You'll need to store a separate field, let's call it date
, that just contains the date (e.g. 2018/01/30
) and not the time. You'll then be able to query as:
const query = db.collection('items')
.orderBy('count', 'desc')
.where('date', '==', today);
Post a Comment for "Order By A Number Field Where A Timestamp Is On A Given Date In Cloud Firestore?"