Skip to content

Instantly share code, notes, and snippets.

@Viveckh
Last active August 29, 2019 11:56
Show Gist options
  • Save Viveckh/edac2c80b72d7045f67011fe7bbcf8f8 to your computer and use it in GitHub Desktop.
Save Viveckh/edac2c80b72d7045f67011fe7bbcf8f8 to your computer and use it in GitHub Desktop.
Dating App - Firebase Realtime Database Schema - Swipes
"swipes": {
"$uid": {
// Only the user to whom this swipe node pertains to can read and update it by default
".read": "auth.uid === $uid",
".write": "auth.uid === $uid",
".validate": "root.child('users/' + $uid).exists()",
"$candidate_uid": {
// A user can read another user's swipe details only for the record that applies to them
".read": "auth.uid === $candidate_uid",
// Validate that the candidate exists in users and a user is not swiping on himself
".validate": "root.child('users/' + $candidate_uid).exists() && $candidate_uid != $uid",
"swipe_type": { ".validate": "newData.isString() && (newData.val() == 'left' || newData.val() == 'right')" }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment