Last active
June 26, 2017 11:34
-
-
Save anhtuank7c/fd230602ac1891ac9504679684cf9f1d to your computer and use it in GitHub Desktop.
A simple chat firebase data structure.
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
{ | |
"messages" : { | |
"-KgxvzeIQc30MLWT5zwX" : { | |
"-Kgxvzf58f8-GHJxvwWG" : { | |
"createdAt" : 1491392789639, | |
"text" : "A", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
}, | |
"-Kgxx3mJQqQ-zojEa-Ji" : { | |
"createdAt" : 1491393072723, | |
"text" : "Abc", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
}, | |
"-KgxxAN2VgJCGBGz0gx8" : { | |
"createdAt" : 1491393099745, | |
"text" : "Continue", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
}, | |
"-KgxxC-49-_6xeeY3VRj" : { | |
"createdAt" : 1491393106400, | |
"text" : "OK", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
}, | |
"-KgxxG4DCbtdsQfG3X3o" : { | |
"createdAt" : 1491393123617, | |
"text" : "yes", | |
"user" : { | |
"_id" : "HrxJOCFUxjXBc7iFQrm1yiz9Eqv2", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/17498435_110189046190702_2221072412717518049_n.jpg?oh=afebb3bdcbca9c09c00b075ef7f22467&oe=599210C0", | |
"name" : "Ngọc Trinh" | |
} | |
}, | |
"-KgxxKAtoLzh9whUsf0j" : { | |
"createdAt" : 1491393139953, | |
"text" : "LOL", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
}, | |
"-KgxxLOrFsQNjruw3Sd0" : { | |
"createdAt" : 1491393145446, | |
"text" : "kaka", | |
"user" : { | |
"_id" : "HrxJOCFUxjXBc7iFQrm1yiz9Eqv2", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/17498435_110189046190702_2221072412717518049_n.jpg?oh=afebb3bdcbca9c09c00b075ef7f22467&oe=599210C0", | |
"name" : "Ngọc Trinh" | |
} | |
}, | |
"-Kgxys96h1CSnSjOEmLv" : { | |
"createdAt" : 1491393545542, | |
"text" : "are you ok?", | |
"user" : { | |
"_id" : "HrxJOCFUxjXBc7iFQrm1yiz9Eqv2", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/17498435_110189046190702_2221072412717518049_n.jpg?oh=afebb3bdcbca9c09c00b075ef7f22467&oe=599210C0", | |
"name" : "Ngọc Trinh" | |
} | |
}, | |
"-KgxyvAX9m9GttdbBy28" : { | |
"createdAt" : 1491393558403, | |
"text" : "Thank. I am ok.", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
}, | |
"-KgxzR_cIJnoWM2r54Jf" : { | |
"createdAt" : 1491393694464, | |
"text" : "Out of network", | |
"user" : { | |
"_id" : "HrxJOCFUxjXBc7iFQrm1yiz9Eqv2", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/17498435_110189046190702_2221072412717518049_n.jpg?oh=afebb3bdcbca9c09c00b075ef7f22467&oe=599210C0", | |
"name" : "Ngọc Trinh" | |
} | |
}, | |
"-Kgxzd0mTSHmt6QNvo6X" : { | |
"createdAt" : 1491393745588, | |
"text" : "Again", | |
"user" : { | |
"_id" : "HrxJOCFUxjXBc7iFQrm1yiz9Eqv2", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/17498435_110189046190702_2221072412717518049_n.jpg?oh=afebb3bdcbca9c09c00b075ef7f22467&oe=599210C0", | |
"name" : "Ngọc Trinh" | |
} | |
}, | |
"-Kgxzn98gCDazwn0mNw4" : { | |
"createdAt" : 1491393835044, | |
"text" : "once again", | |
"user" : { | |
"_id" : "HrxJOCFUxjXBc7iFQrm1yiz9Eqv2", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/17498435_110189046190702_2221072412717518049_n.jpg?oh=afebb3bdcbca9c09c00b075ef7f22467&oe=599210C0", | |
"name" : "Ngọc Trinh" | |
} | |
}, | |
"-KgxzqcnbJcHJcKaUGCK" : { | |
"createdAt" : 1491393801162, | |
"text" : "I am still here", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
} | |
}, | |
"-Kgxx679kvIPFXGUCrvC" : { | |
"-Kgxx68dndd4wCMJFkFs" : { | |
"createdAt" : 1491393082387, | |
"text" : "Hello", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
}, | |
"-Kgxx7rd6KcBuSJE77cC" : { | |
"createdAt" : 1491393089445, | |
"text" : "Oh", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
}, | |
"-KgxxHSIfDvBtAwJRU2N" : { | |
"createdAt" : 1491393128741, | |
"text" : "LOL", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
}, | |
"-KgxyzINimTNEoEkjdJB" : { | |
"createdAt" : 1491393575054, | |
"text" : "Hi there", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
}, | |
"-KgxzA1ahZi4joonV1IN" : { | |
"createdAt" : 1491393622588, | |
"text" : "Tai sap lai can roomDetails?", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
}, | |
"-KgxzDtLyq9vF4Zh09_0" : { | |
"createdAt" : 1491393638380, | |
"text" : "Bi mat, se noi sau nhe!", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
} | |
}, | |
"-Kgxz2OqSYNBy5QhIIKX" : { | |
"-Kgxz2RxrRSGhXvxfV2I" : { | |
"createdAt" : 1491393591961, | |
"text" : "Hi there", | |
"user" : { | |
"_id" : "HrxJOCFUxjXBc7iFQrm1yiz9Eqv2", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/17498435_110189046190702_2221072412717518049_n.jpg?oh=afebb3bdcbca9c09c00b075ef7f22467&oe=599210C0", | |
"name" : "Ngọc Trinh" | |
} | |
}, | |
"-Kgxz5I3HA8xJJVOmCAv" : { | |
"createdAt" : 1491393603199, | |
"text" : "3 rooms", | |
"user" : { | |
"_id" : "HrxJOCFUxjXBc7iFQrm1yiz9Eqv2", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/17498435_110189046190702_2221072412717518049_n.jpg?oh=afebb3bdcbca9c09c00b075ef7f22467&oe=599210C0", | |
"name" : "Ngọc Trinh" | |
} | |
} | |
} | |
}, | |
"roomDetails" : { | |
"-KgxvzeIQc30MLWT5zwX" : { | |
"createdAt" : 1491393834863, | |
"text" : "once again", | |
"user" : { | |
"_id" : "HrxJOCFUxjXBc7iFQrm1yiz9Eqv2", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/17498435_110189046190702_2221072412717518049_n.jpg?oh=afebb3bdcbca9c09c00b075ef7f22467&oe=599210C0", | |
"name" : "Ngọc Trinh" | |
} | |
}, | |
"-Kgxx679kvIPFXGUCrvC" : { | |
"createdAt" : 1491393638178, | |
"text" : "Bi mat, se noi sau nhe!", | |
"user" : { | |
"_id" : "t8U329k7dEfyW0UYM38Kodoqzy22", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"name" : "Tuan Anh Nguyen" | |
} | |
}, | |
"-Kgxz2OqSYNBy5QhIIKX" : { | |
"createdAt" : 1491393602997, | |
"text" : "3 rooms", | |
"user" : { | |
"_id" : "HrxJOCFUxjXBc7iFQrm1yiz9Eqv2", | |
"avatar" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/17498435_110189046190702_2221072412717518049_n.jpg?oh=afebb3bdcbca9c09c00b075ef7f22467&oe=599210C0", | |
"name" : "Ngọc Trinh" | |
} | |
} | |
}, | |
"rooms" : { | |
"-KgxvzeIQc30MLWT5zwX" : { | |
"HrxJOCFUxjXBc7iFQrm1yiz9Eqv2" : true, | |
"t8U329k7dEfyW0UYM38Kodoqzy22" : true | |
}, | |
"-Kgxx679kvIPFXGUCrvC" : { | |
"jEIAfqDpJjWWUUXaecSmMk3U7vu1" : true, | |
"t8U329k7dEfyW0UYM38Kodoqzy22" : true | |
}, | |
"-Kgxz2OqSYNBy5QhIIKX" : { | |
"HrxJOCFUxjXBc7iFQrm1yiz9Eqv2" : true, | |
"jEIAfqDpJjWWUUXaecSmMk3U7vu1" : true | |
} | |
}, | |
"users" : { | |
"HrxJOCFUxjXBc7iFQrm1yiz9Eqv2" : { | |
"displayName" : "Ngọc Trinh", | |
"email" : "ngoctrinh@example.com", | |
"findable" : true, | |
"photoURL" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/17498435_110189046190702_2221072412717518049_n.jpg?oh=afebb3bdcbca9c09c00b075ef7f22467&oe=599210C0", | |
"rooms" : { | |
"-KgxvzeIQc30MLWT5zwX" : true, | |
"-Kgxz2OqSYNBy5QhIIKX" : true | |
} | |
}, | |
"jEIAfqDpJjWWUUXaecSmMk3U7vu1" : { | |
"displayName" : "User demo 1", | |
"email" : "user_demo_1@gmail.com", | |
"findable" : true, | |
"photoURL" : "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/00/00965ed2355b37a7b85532e2f2c565b63546b9c8_full.jpg", | |
"rooms" : { | |
"-Kgxx679kvIPFXGUCrvC" : true, | |
"-Kgxz2OqSYNBy5QhIIKX" : true | |
} | |
}, | |
"t8U329k7dEfyW0UYM38Kodoqzy22" : { | |
"displayName" : "Tuan Anh Nguyen", | |
"email" : "anhtuank7c@example.com", | |
"findable" : true, | |
"photoURL" : "https://scontent.xx.fbcdn.net/v/t1.0-1/p100x100/16426170_972992216166359_6914329574455833352_n.jpg?oh=0ff992858f7f4785b0a1d60a65118144&oe=59517ACD", | |
"rooms" : { | |
"-KgxvzeIQc30MLWT5zwX" : true, | |
"-Kgxx679kvIPFXGUCrvC" : true | |
} | |
} | |
} | |
} |
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
{ | |
"rules": { | |
"users": { | |
".read": "auth != null", | |
".indexOn": "findable", | |
"$user_id": { | |
".read": "auth != null", | |
"rooms": { | |
".write": "auth != null" | |
} | |
} | |
}, | |
"roomDetails": { | |
"$room_id": { | |
".read": "auth != null && root.child('rooms/' + $room_id + '/' + auth.uid).exists()", | |
".write": "auth != null && newData.child('user/_id').val() === auth.uid && | |
root.child('rooms/' + $room_id + '/' + auth.uid).exists()", | |
".validate": "newData.child('createdAt').val() <= now && newData.child('user').exists()" | |
} | |
}, | |
"rooms": { | |
".read": "auth != null", | |
".write": "auth != null", | |
"$room_id": { | |
".read": "data.child(auth.uid).exists()", | |
"$user_id": { | |
".write": "auth != null && newData.child(auth.uid).exists()", | |
} | |
} | |
}, | |
"messages": { | |
"$room_id": { | |
".read": "root.child('rooms/' + $room_id + '/' + auth.uid).exists()", | |
".write": "auth != null", | |
"$message_id": { | |
".write": "auth != null" | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment