Last active
August 29, 2019 11:56
-
-
Save Viveckh/edac2c80b72d7045f67011fe7bbcf8f8 to your computer and use it in GitHub Desktop.
Dating App - Firebase Realtime Database Schema - Swipes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
"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