Last active
September 21, 2023 10:05
-
-
Save Viveckh/0998545fac72b21798d7d48a65009f09 to your computer and use it in GitHub Desktop.
Dating App - Firebase Realtime Database Schema - Matches
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
"matches": { | |
"$uid": { | |
// Only the user to whom this match node pertains to can read it by default | |
".read": "auth.uid === $uid", | |
".validate": "root.child('users/' + $uid).exists()", | |
"$match_uid": { | |
// A user can read another user's match details only for the record that applies to them | |
".read": "auth.uid === $match_uid", | |
// A match can be added by either of the users in the pair, as long as they can verify they are swiped right by the other user | |
".write": "(auth.uid === $uid && root.child('swipes/' + $match_uid + '/' + $uid + '/swipe_type').val() === 'right') || (auth.uid === $match_uid && root.child('swipes/' + $uid + '/' + $match_uid + '/swipe_type').val() === 'right')", | |
// Creating a new match requires to have chat_id, and timestamp node | |
".validate": "root.child('users/' + $match_uid).exists() && !data.exists() && newData.hasChildren(['chat_id', 'timestamp'])", | |
"chat_id": { ".validate": "root.child('chats/' + newData.val() + '/members/' + $uid).exists() && root.child('chats/' + newData.val() + '/members/' + $match_uid).exists()" }, | |
"timestamp": { ".validate": "newData.val() <= now" } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's a helpful resource for those looking to understand the data structure involved in building such apps. If you're interested in diving deeper into the development process, this guide on how to make a dating app at https://www.cleveroad.com/blog/how-to-make-a-dating-app/ provides valuable insights into the broader aspects of creating a successful dating platform.