Reputation: 998
Firebase database :
Data structure
"transactiondate"
|-->10082017 //new value comes everyday
| |-->User_unique_id
| |-->"key":"value"
I have a firebase database rule as below,
"transactiondate":{
"now()":{
"$user_id": {
".write": "$user_id === auth.uid",
".read": false}}}
The users need to write to their own space under transactiondate/10082017/uniqueidhere/ but the now function is not validating the date as 10082017 or in any format i tried including epoch.
Upvotes: 2
Views: 1228
Reputation: 772
What about something like this?
"rules": {
"transactiondate": {
"$date_val": {
"$user_id" : {
".read": false,
".write": "$user_id === auth.uid"
}
}
}
}
$date_val is just a placeholder for the actual transaction date ("10082017" in your example). You don't need to use anything like now() to try to get an actual date into the rules.
This should work as long as there are no other types of children under the "transactiondate" node. If there are other types of children, you may need to supply some more samples of your data.
Upvotes: 2