Is there a way to query for documents where the userId matches and the document started or ended this day? I know firestore supports “OR” operator but im not sure if im implementing the implicit “and” operator correctly
Im trying to achieve something like this
let q = query(
sessionsRef,
(
orderBy("createdAt"),
where("user", "==", userId),
or
(
(
where("endedAt", ">=", Timestamp.fromDate(startOfDay)),
where("endedAt", "<=", Timestamp.fromDate(endOfDay))
),
(
where("startedAt", ">=", Timestamp.fromDate(startOfDay)),
where("startedAt", "<=", Timestamp.fromDate(endOfDay))
)
)
)
);
I prefer not to use two queries and combine the results, unless there are no other alternatives. The only issue with using two queries is that I would get a lot of duplicated data