Skip to content

Instantly share code, notes, and snippets.

@tejasrsuthar
Created June 17, 2017 06:15
Show Gist options
  • Save tejasrsuthar/a46e12b3af94b5c6de54fea17180fe06 to your computer and use it in GitHub Desktop.
Save tejasrsuthar/a46e12b3af94b5c6de54fea17180fe06 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