Skip to content

Instantly share code, notes, and snippets.

@mrbarletta
Created May 17, 2017 22:31
Show Gist options
  • Select an option

  • Save mrbarletta/81c8039e18e48f73ef4c483bd60b5eb3 to your computer and use it in GitHub Desktop.

Select an option

Save mrbarletta/81c8039e18e48f73ef4c483bd60b5eb3 to your computer and use it in GitHub Desktop.
How to structure Firebase data and rules for sharing data between users
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/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment