I need to retrieve from firebase some objects contained in an array by selecting only those within a certain time range. I checked the firebase documentation but when I try to use my code to send a GET request, it returns nothing. I need some help to understand what I am doing wrong and what's the right way to make this kind of query with firebase and node.js.
Here you can see how my data are structured and my code for the GET request.
export const getLastWeekDataFromDatabase = async (req: IdRequest, res: Response) => {
const deviceId = req.params.deviceId
try {
const reference = db.collection("AQData")
.doc(deviceId)
.collection("history")
const document = await reference
.orderBy("timestamp").startAt(1660483660946).endAt(1660483712221)
.get()
res.status(200).json(document.forEach(doc => {
doc.data()
}))
} catch(error) {
res.status(500).json(error)
};
};