I have already created react app and I'm using firebase firestore. So at the start of using I didn't have any problems, until I found that I need to create a query like that:
db.collection('schedule')
.where('working_day', '>=', new Date())
.where('master', '==', masterId)
.orderBy('working_day', 'desc')
.get();
I have a collection called schedule and this schedule collection has list of documents. Each document has structure:
working_day: timestamp;
start_hour: number;
end_hour: number;
master: string;
When I called this query - I didn't see any result (request is gone, but no results at all). Someone suggest me to add composite indexing and It must solve this problem I did it using firestore indexing tab and now I have this indexing:
Collection ID Fields indexed Query scope Status
schedule working_day Descending master Descending Collection Enabled
It has been successfully applied - but still my request without any result. Also I know that firestore could notice me that I need to apply this indexing and provide me the link - but I don't see this link. Where I should find this? Or maybe I do something wrong?
Break my head for the 2 days and didn't find why I have this issue
It looks like working.day is stored in your firestore database as a timestamp but your query condition is comparing against a javascript date object which could be causing an issue. Try replacing the date object with a firebase timestamp like the code below.
db.collection('schedule')
.where('working_day', '>=', new firebase.firestore.Timestamp.now())
.where('master', '==', masterId)
.orderBy('working_day', 'desc')
.get();