Skip to content

Instantly share code, notes, and snippets.

@antoniorrm
Last active June 27, 2021 21:03
Show Gist options
  • Save antoniorrm/708cdee7b432a2aadd9f573457a07516 to your computer and use it in GitHub Desktop.
Save antoniorrm/708cdee7b432a2aadd9f573457a07516 to your computer and use it in GitHub Desktop.
{
"rules": {
"rooms": {
".read": false,
".write": "auth != null",
"$roomId": {
".read": true,
".write": "auth != null && (!data.exists() || data.child('authorId').val() == auth.id)",
"questions": {
".read": true,
".write": "auth != null && (!data.exists() || data.parent().child('authorId').val() == auth.id)",
"likes": {
".read": true,
".write": "auth != null && (!data.exists() || data.child('authorId').val() == auth.id)",
}
}
}
}
}
}
{
"rules": {
"rooms": {
".read": false,
".write": false,
"$roomId": {
".read": "!root.child('/rooms/' + $roomId + '/endedAt').exists() || data.child('authorId').val() == auth.uid ",
".write": "auth != null && (!data.exists() || data.child('authorId').val() == auth.uid)",
"questions": {
".read": "!root.child('/rooms/' + $roomId + '/endedAt').exists()",
".write": false,
"$questionId":{
".read": true,
".write": "auth != null && !root.child('/rooms/' + $roomId + '/endedAt').exists() && (!data.exists() || data.child('author/id').val() == auth.uid)",
"likes": {
".read": true,
".write": "auth != null",
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment