Changes

Jump to: navigation, search

Firebase Realtime Database Rules

99 bytes added, 30 August
no edit summary
As previously outlined, the .read and .write rule types are used to declare the circumstances under which the data in a realtime database may be read and written by users.
<htmlet>firebase_android</htmlet>
=== Data Validation Rules ===
The above example establishes a rule that checks the uid in the profiles section of the database. If the auth variable is null (in other words the user has not been authenticated), or the uid read from the database node for which access is being requested does not match the uid of the current user access is denied. In order to fully explain the way in which the rule works, it is first necessary to understand the concept of $ variables.
<htmlet>firebase_android</htmlet>
== $ Variables ==
=== 'John Wilson'"
</pre>
<htmlet>firebase_android</htmlet>
The above examples test whether data already contained within the database meets specified criteria. The newData variable can be used in a similar manner to verify that the data about to be written to the database complies with the database rule declaration. In the following example, the rule requires that the data being written to the database contain a string value at the path /data/username and that the existing database has a true Boolean value at the /data/settings/updates key path:

Navigation menu