In NodeJS, I am trying to get all cases with caseStatus "active" and apptTimeInEpochSeconds within a range.
I am trying to achieve it using the below code:
const casesRef = db.collection("rch" + "/hospital/cases");
const query = casesRef
.where("patientDetails.caseStatus", "==", keys.active)
.where("patientDetails.apptTimeInEpochSeconds", ">", 1601461817)
.where("patientDetails.apptTimeInEpochSeconds", "<", 1601461819)
try {
const snapshot = await query.get();
if (!snapshot.exists) {
// Active cases exist
const _apptReminderCases = snapshot.docs.map((doc) => doc.data());
}catch (error) {
console.log("errorInCatchBlock: ", error);
}
And I get the below error, when I use <
or >
operators (as you can see in my above code)
The query requires an index. You can create it here: https://console.firebase.google.com/v1/r/...
When I try the below code without the <
operator I get the object
const casesRef = db.collection("rch" + "/hospital/cases");
const query = casesRef
.where("patientDetails.caseStatus", "==", keys.active)
.where("patientDetails.apptTimeInEpochSeconds", "==", 1601461818)
Please advice how I could fix this issue.