I want to restrict a time period using Firestore.
For example a user can access an app only between 9:00 and 21:00. I don't know how to store the restricted time. At first I though I should use timestamp type. But I want for user to access based on hours. So I mean I need just hours.
Based on this article Storing time only in Firestore, Should I save the time like this?
- startAccess : 900
- endAccess: 2100
This data type is Int
type.
And if I save those type in Firestore, I don't know how to filter it exactly. I read an official document and we can restrict an access like this.
allow read: if
request.time > something rule?
But if I use just Int
type above, I think I can't filter the access time.
How do I achieve it?
I haven't test this yet, But should look like:
allow read: if request.time.hours() >= 9 && request.time.hours() < 21;
Document Interface: Timestamp