So after building a chat app with angularjs and PHP I realized it was horrible for server performance and decided to give firebase a try using angularjs to talk with firebase(angularfire) right now I have hit a little roadblock and can't seem to figure out how to accomplish displaying a users chat rooms he's apart of. Please note this is my FIRST time using NoSql structure.
Currently my structure is like so:
{
"-K4KXS4k3mftFMe7jy_g" : {
"members" : {
"guest:Aaaa1aa" : {
"user1" : "Aaaa1aa",
"user2" : "guest"
}
},
"messages" : {
"guest:Aaaa1aa" : {
"-K4LdBwkMe7dcshqCXxW" : {
"content" : "gg",
"from" : "Aaaa1aa"
}
}
},
"rooms" : {
"guest:Aaaa1aa" : {
"roomname" : "guestAaaa1aa",
"type" : "private"
}
}
}
}
I want to check if
members->'key'->user1 == 'Aaaa1aa'
but the way I construct the key for each members data(from room key) is passed two parameters when the user clicks on 'message'(creates new room or opens existing room) in another function and that is their user name and the users profile name they clicked on. hence the keys with the delimiter ':' (guest:Aaaa1aa).
So my question is can I check if the members key contains a substring value ? sort of like explode in PHP.
What I want my query to be like:
select uniqueid(room_name) from members where user1 = 'passed value'
and if above is possible would the below be possible as well ?
select uniqueid(room_name) from members where user1 = 'passed value' || user2 = 'passed value'
thanks for any help, if I am structuring this wrong please let me know and point me into the right direction.