Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I need help on creating a firebase database rule. The use case is like this: the user (gamer) have 3 treasure boxes which can hold any treasure. User can purchase extra treasure box. So the tree structure in firebase database I came up is:

user
  |- settings
       |- max-t-box : 3
  |- boxes
       |- 1 : {} // a complicated data for the treasure or null
       |- 2 : {} // a complicated data for the treasure or null
       |- 3 : {} // a complicated data for the treasure or null

The rule on 'user/settings/max-t-box' is trivial: user read only and not allowed to write (it can only be modified by server side admin).

The rule under 'user/boxes' is supposed to be: the key of new data should be a number and it's value should be > 0 and <= 'user/setting/max-t-box' value.

According to firebase document, I can use $variable to capture path segment, however it does not provide enough api for me to check the path node name value.

So far the solution I come up is to write rules for path 'user/boxes/1', 'user/boxes/2' and 'user/boxes/3'. However this really looks stupid after user buys many boxes.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
767 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...