Untitled
unknown
plain_text
a year ago
1.7 kB
6
Indexable
Never
const fetchReservationsForDate = async (date: moment.Moment): Promise<Reservation[]> => { const startOfDay = date.startOf("day").toDate(); //WORKS! const endOfDay = date.endOf("day").toDate(); //WORKS! const reservationsCollection = db.collection("reservations"); const snapshot = await reservationsCollection .where("dateTime", ">=", startOfDay) .where("dateTime", "<=", endOfDay) .where("status", "==", ReservationStatus.CONFIRMED) .get(); const reservations: Reservation[] = []; snapshot.forEach((doc) => { const data = doc.data(); const res = data as Reservation res.dateTime = moment(res.dateTime.toDate()); reservations.push(res); }); return reservations; }; //This does not work - nothing gets returned const fetchReservationsForDate = async (date: moment.Moment): Promise<Reservation[]> => { const startOfDay = date.startOf("day"); const endOfDay = date.endOf("day"); const reservationsCollection = db.collection("reservations"); const snapshot = await reservationsCollection .where("dateTime", ">=", startOfDay.toDate()) //DOES NOT WORK! .where("dateTime", "<=", endOfDay.toDate()) //DOES NOT WORK! .where("status", "==", ReservationStatus.CONFIRMED) .get(); const reservations: Reservation[] = []; snapshot.forEach((doc) => { const data = doc.data(); const res = data as Reservation res.dateTime = moment(res.dateTime.toDate()); reservations.push(res); }); return reservations; };