How to create firebase rule for user defined time period

Viewed 17

I have a firebase query that looks like:

query(
  edata, 
  where("dateDate", ">=", new Date(monthStart.date.toString()),
  where("dateDate", "<=", new Date(monthEnd.date.toString()),
  where("uid", "==", this.state.user.uid)))
)

I have documents which contain the date of document creation, ie dateDate. My app has a calendar page and so I really only need to query data for the particular month the user looks at. This is why there are where conditions constraining between the start and end of a given month.

With a firebase rule of:

allow read, create, update: if request.auth.uid != null &&
                               request.auth.uid == resource.data.uid

the above query fails, but if I now change the query to below, without the dates:

query(edata, where("uid", "==", this.state.user.uid))

then the query goes through. How do I go about adding a rule that queries data based on a user defined month?

0 Answers
Related