Skip to content Skip to sidebar Skip to footer

Firestore Use Database/server Time For Query

I have a collection in Firestore that contains a string for the next 365 days. It's effectively a codeword that our app needs to display on that particular day. We've noticed that

Solution 1:

You can't use the server's time in the query, since the value you query for has to come from the client. But you could probably secure the data to only allow the user to read the data for "today". And since you'd do that in Firestore's server-side security rules, you could use the server-side timestamp in it.

Your current query could be secured with a query-filter based on document fields and the request.time field.

You could also consider foregoing the query, and just making a single document each date, i.e. with a ID like 2018-11-13 and then: 1) have the client request the document for today, 2) restrict access to that specific document in security rules.


Post a Comment for "Firestore Use Database/server Time For Query"