I'm trying to build a rate limiter that saves timestamp to realtime database and returns object which has values from only last 60 seconds to eventually count them, however this returns null every single time, I can see the writes passing to the database, been at this for hours following example from Rate limiting for Google/Firebase cloud functions? but not having any luck.
exports.testRateLimiter =
functions.https.onRequest(async (req, res) => {
var ref = db.ref('rateLimiter/test');
var time = Date.now()
var timeStr = time.toString()
ref.push(timeStr)
var orderByVal = Date.now()-60000
var orderByValStr = orderByVal.toString()
ref.orderByKey().startAt(orderByValStr).once("value", function(snapshot) {
console.log(snapshot.val());
});
});