Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Firebase Database Rules How To Deal With - Olek...
Search
GDG Ternopil
January 21, 2017
Programming
0
72
Firebase Database Rules How To Deal With - Oleksandr Pidlisnyi
Firebase Database Rules How To Deal With - Oleksandr Pidlisnyi
GDG Ternopil
January 21, 2017
Tweet
Share
More Decks by GDG Ternopil
See All by GDG Ternopil
Semi supervised learning with Autoencoders by Ілля Горев
gdgternopil
1
73
Застосування ML в реальних проектах - Андрій Дерень
gdgternopil
1
100
Android Architecture Components by Ihor Dzikovskyy
gdgternopil
1
150
First look at Room Persistence by Oleksiy Sazhko
gdgternopil
1
97
Mobile Applications Architecture by Constantine Mars
gdgternopil
2
71
Tuning your SQLite with SQLDelight & SQLBrite - Mkhytar Mkhoian
gdgternopil
0
260
Speeding up development with AutoValue - Andrii Rakhimov
gdgternopil
0
73
The Mistery of Gradle Plugins - Dmytro Zaitsev
gdgternopil
0
62
Xamarin Build native Android & iOS apps with C# - Vitalii Smal
gdgternopil
0
91
Other Decks in Programming
See All in Programming
SwiftUIで単方向アーキテクチャを導入して得られた成果
takuyaosawa
0
270
Amazon ECS とマイクロサービスから考えるシステム構成
hiyanger
2
550
昭和の職場からアジャイルの世界へ
kumagoro95
1
370
WebDriver BiDiとは何なのか
yotahada3
1
140
Writing documentation can be fun with plugin system
okuramasafumi
0
120
Linux && Docker 研修/Linux && Docker training
forrep
24
4.5k
Multi Step Form, Decentralized Autonomous Organization
pumpkiinbell
1
730
Introduction to kotlinx.rpc
arawn
0
690
個人アプリを2年ぶりにアプデしたから褒めて / I just updated my personal app, praise me!
lovee
0
340
Unity Android XR入門
sakutama_11
0
150
[JAWS-UG横浜 #79] re:Invent 2024 の DB アップデートは Multi-Region!
maroon1st
1
140
Rails アプリ地図考 Flush Cut
makicamel
1
120
Featured
See All Featured
The Language of Interfaces
destraynor
156
24k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
133
33k
The Invisible Side of Design
smashingmag
299
50k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
193
16k
Fireside Chat
paigeccino
34
3.2k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Building Adaptive Systems
keathley
40
2.4k
Practical Orchestrator
shlominoach
186
10k
Git: the NoSQL Database
bkeepers
PRO
427
64k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
Transcript
Firebase Database Rules How To Deal With Oleksandr Pidlisnyi Senior
Software Engineer @ Perfectial LLC GDG Lviv
Firebase Realtime Database
WHAT IF I TELL YOU IT IS NOT DATABASE
None
Database? SQL NoSQL JSON
Realtime
None
Offline
Accessible from Client Devices Android iOS Web SDK for Node.js,
C++, JAVA, Unity
Rules .read .write .validate .indexOn
now root newData data auth $ variables Predefined variables
provider uid token auth
.validate { "rules": { "foo": { ".validate": "newData.isString() && newData.val().length
< 100" } } }
.indexOn – orderByChild { "lambeosaurus": { "height": 2.1, "length": 12.5,
"weight": 5000 }, "stegosaurus": { "height": 4, "length": 9, "weight": 2500 } }
.indexOn – orderByChild { "rules": { "dinosaurs": { ".indexOn": ["height",
"length"] } } }
.indexOn – orderByValue { "scores": { "bruhathkayosaurus": 55, "lambeosaurus": 21,
"linhenykus": 80, "pterodactyl": 93, "stegosaurus": 5, "triceratops": 22 } }
.indexOn – orderByValue { "rules": { "scores": { ".indexOn": ".value"
} } }
.read && .write { "rules": { "foo": { ".read": true,
".write": false } } }
.read && .write { "rules": { "users": { "$uid": {
".write": "$uid === auth.uid" } } } }
Magic { "users": { "John Doe": { "rules": { "blog":
true } }, "John Snow": { "rules": { "blog": false } } }
Magic "blog": { "1": { "title": "Blog Post 1" },
"2": { "title": "Blog Post 2" } } }
Magic "blog": { ".read": true, ".write": "root.child('users').child(auth.uid).child('rules').child('blog').val() === true" }
Magic "$collection": { ".read": true, ".write": "root.child('users').child(auth.uid).child('rules').child($collection).val() === true" }
Magic { "users": { "John Doe": { "rules": { "blog":
{ "read": true, "write": false } } } } }
Magic "$collection": { ".read": "root.child('users').child(auth.uid).child('rules').child($collection).child ('read').val() === true", ".write": "root.child('users').child(auth.uid).child('rules').child($collection).child
('write').val() === true" }
+OleksandrPidlisnyi @opidlisnyi fb.me/opidlisnyi Questions? Thank you!