How to structure Firebase data and rules for sharing data between users?

后端 未结 1 875
鱼传尺愫
鱼传尺愫 2021-01-01 04:13

Currently I have a simple todo app whereby users can create a list then tick off items as done. The data is structured as follows: \'/acc_\' + USER_ID +\'/done\' and \'/acc_

相关标签:
1条回答
  • 2021-01-01 05:05

    Since the user decides who'd they like to share the list with, I'd store that information in the user data itself. For example:

    {
      "rules": {
        "$userPath": {
          ".write": "$userPath == 'acc_' + auth.id",
          ".read": "$userPath == 'acc_' + auth.id || root.child($userPath).child('shared').hasChild(auth.id)"
        }
      }
    }
    

    And then store the list of users the data is shared with in acc_userid/shared/

    0 讨论(0)
提交回复
热议问题