Skip to content

Instantly share code, notes, and snippets.

@Viveckh
Last active August 29, 2019 11:57
Show Gist options
  • Save Viveckh/9cc2e476d246678137e8e4e22ed40721 to your computer and use it in GitHub Desktop.
Save Viveckh/9cc2e476d246678137e8e4e22ed40721 to your computer and use it in GitHub Desktop.
Dating App - Firebase Realtime Database Schema - User
"users": {
// Anyone who is authenticated can read user info
".read": "auth.uid != null",
"$uid": {
// But a user can only update their own info
".write": "auth.uid === $uid",
// At least the name of the user should be provided to set
".validate": "newData.hasChildren(['name'])",
"name": { ".validate": "newData.exists() && newData.isString()" },
// Birth date fields can only be changed once
"birth_year": { ".validate": "!data.exists() && newData.exists()" },
"birth_month": { ".validate": "!data.exists() && newData.exists()" },
// Location can be updated as frequenty as users choose to
"current_country": { ".validate": "newData.exists() && newData.isString()" },
"current_city": { ".validate": "newData.exists() && newData.isString()" },
"current_zip": { ".validate": "newData.exists()" }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment