A short (quickstart) version of the Tunnels & Trolls rules, including a solo adventure you can play by yourself, and a group adventure you can play with your friends. This is what we gave away on F...
Firebase In IOS Programming Instructions
The purpose of this study is to introduce everyone with the amazing features of Firebase that can be useful to rocket boost an Application. Traditionally to get best out of an app we need a huge, expensive, bulky methods or code to be used or impleme
15/3/2016
Security & Rules API Firebase
FIREBASE
Security & Rules API Rule
Types .read
CODE EXAMPLE
Grants a client read access to a Firebase location.
.write
CODE EXAMPLE
Grants a client write access to a Firebase location.
.validate
CODE EXAMPLE
Used once a .write rule has granted access, to ensure that the data being written conforms to a specific schema.
.indexOn
CODE EXAMPLE
Improves query performance by telling Firebase against which keys you want your data indexed.
https://www.firebase.com/docs/security/api/
1/9
15/3/2016
Security & Rules API Firebase
Variables auth
CODE EXAMPLE
A variable containing the token payload if a client is authenticated or if the client isn't authenticated.
$location
A variable that can be used to reference the key of a used earlier in a rule structure.
now
null
CODE EXAMPLE
$location
that was
CODE EXAMPLE
Contains the number of milliseconds since the Unix epoch according to the Firebase servers.
root
CODE EXAMPLE
A RuleDataSnapshot corresponding to the current data at the root of your Firebase.
data
https://www.firebase.com/docs/security/api/
CODE EXAMPLE
2/9
15/3/2016
A
Security & Rules API Firebase
RuleDataSnapshot
corresponding to the current data in Firebase at the
location of the currently executing rule.
newData
A
CODE EXAMPLE
RuleDataSnapshot
corresponding to the data that will result if the write is
allowed.
RuleDataSnapshot Methods val()
CODE EXAMPLE
val()
Gets the primitive value (string, number, boolean, or RuleDataSnapshot
child()
parent()
Gets a
) from this
.
CODE EXAMPLE
child(childPath)
Gets a
null
RuleDataSnapshot
for the location at the specified relative path.
CODE EXAMPLE
parent()
RuleDataSnapshot
https://www.firebase.com/docs/security/api/
for the parent location. 3/9
15/3/2016
Security & Rules API Firebase
hasChild()
Returns
CODE EXAMPLE
hasChild(childPath)
true
hasChildren()
if the specified child exists.
CODE EXAMPLE
hasChildren([children])
Checks for the existence of children.
exists()
CODE EXAMPLE
exists()
Returns
true
getPriority()
if this
RuleDataSnapshot
Returns
isString()
CODE EXAMPLE
getPriority()
Gets the priority of the data in a
isNumber()
contains any data.
RuleDataSnapshot
.
CODE EXAMPLE
isNumber()
true
if this
isString()
https://www.firebase.com/docs/security/api/
RuleDataSnapshot
contains a numeric value.
CODE EXAMPLE 4/9
15/3/2016
Security & Rules API Firebase
Returns
true
isBoolean()
Returns
if this
RuleDataSnapshot
contains a string value.
CODE EXAMPLE
isBoolean()
true
if this
RuleDataSnapshot
contains a boolean value.
String
Properties length
CODE EXAMPLE
length
Returns the length of the string.
Methods contains()
Returns
contains(substring)
true
beginsWith()
Returns
if the string contains the specified substring.
beginsWith(substring)
true
CODE EXAMPLE
CODE EXAMPLE
if the string begins with the specified substring.
https://www.firebase.com/docs/security/api/
5/9
15/3/2016
Security & Rules API Firebase
endsWith()
Returns
replace()
endsWidth(substring)
true
CODE EXAMPLE
if the string ends with the specified substring.
replace(substring, replacement)
CODE EXAMPLE
Returns a copy of the string with all instances of a specified substring replaced with the specified replacement string.
toLowerCase()
toLowerCase()
CODE EXAMPLE
Returns a copy of the string converted to lower case.
toUpperCase()
toUpperCase()
CODE EXAMPLE
Returns a copy of the string converted to upper case.
matches(regex)
Returns
true
matches(regex)
CODE EXAMPLE
if the string matches the specified regular expression literal.
https://www.firebase.com/docs/security/api/
6/9
15/3/2016
Security & Rules API Firebase
Operators Methods + (add)
CODE EXAMPLE
Used to add variables or for string concatenation.
- (negate or subtract)
CODE EXAMPLE
Used to negate a value or subtract two values in a rules expression.
* (multiply)
CODE EXAMPLE
Used to multiply variables in a rules expression.
/ (divide)
CODE EXAMPLE
Used to divide variables in a rules expression.
% (modulus)
CODE EXAMPLE
Used to find the remainder of dividing one variable by another in a rules expression. https://www.firebase.com/docs/security/api/
7/9
15/3/2016
Security & Rules API Firebase
=== (equals)
CODE EXAMPLE
Used to check if two variables in a rules expression have the same type and value.
!== (not equals)
CODE EXAMPLE
Used to check if two variables in a rules expression are not equal.
&& (AND)
Evaluates to
CODE EXAMPLE
true
if both operands are
true
. Used to evaluate multiple
conditions in a rules expression.
|| (OR)
Evaluates to
CODE EXAMPLE
true
if one operand in the rules expression is
! (NOT)
true
.
CODE EXAMPLE
Evaluates to true if its single operand is false . In rules expressions, the operator is often used to see if data has been written to a location.
> (greater than)
https://www.firebase.com/docs/security/api/
!
8/9
15/3/2016
Security & Rules API Firebase
> (greater than)
CODE EXAMPLE
Used to check if a value is greater than another value in a rules expression.
< (less than)
CODE EXAMPLE
Used to check if a value is less than another value in a rules expression.
>= (greater than or equal to)
CODE EXAMPLE
Used to check if a value is greater than or equal to another value in a rules expression.
<= (less than or equal to)
CODE EXAMPLE
Used to check if a value is less than or equal to another value in a rules expression.