Using firestore v9 I faced up with 1 problem. I have a list of documents, and here 1 of them:
end_hour: 21
master: "WIZ1d74QmvMNDEQKulJyiQNCnad2"
start_hour: 13
working_day: January 11, 2022 at 9:00:00 PM UTC+3
And I try to receive all documents, where master is equal as passed ID and working_day more than passed Date.
const response = await db.collection('schedule')
.where('working_day', '>=', new Date())
.where('master', '==', masterId)
.get();
This request doesn't return any data at all, but when I do request using only first
const response = await db.collection('schedule')
.where('working_day', '>=', new Date()).get()
or when I do query by second field
const response = await db.collection('schedule')
.where('master', '==', masterId)
.get();
Both of them works alone, but not in a pair and I just don't know what is the problem
As mentioned by Caio, you'll need a composite index. From https://cloud.google.com/firestore/docs/query-data/queries#compound_queries, it says "You can chain multiple equality operators (== or array-contains) methods to create more specific queries (logical AND). However, you must create a composite index to combine equality operators with the inequality operators, <, <=, >, and !=."