0
 {
"Events" : {
"events" : {
   "-KT5UMQAhDHs1bB8bKLc" : {
    "activity" : "biking",
    "address" : "54°05'45.8\"N 28°19'02.9\"E, просп. Мира 9, Жодино, Беларусь",
    "category" : "sport",
    "creatorID" : "m11EvlP19OSbEz8XYl2MsNCwGXX2",
    "date" : 1475431200689,
    "forFriends" : true,
    "info" : "вттчтвт",
    "name" : "ьаьатвтвтт",
    "uid" : "-KT5UMQAhDHs1bB8bKLc"
  },

  "-KUSsl7RaL-dVoDCoSYT" : {
    "activity" : "picnic",
    "address" : "Узденский район, Узденский район, Беларусь",
    "category" : "entertainment",
    "creatorID" : "1RXDSJzSEXakxvNdM41Ae3nbHN72",
    "date" : 1477328400000,
    "forFriends" : false,
    "info" : "45",
    "name" : "Test of date",
    "uid" : "-KUSsl7RaL-dVoDCoSYT"
  }
},

"FriendsOF" : {
"NuKweeGv8zTgt1Vi9RcU3i1u86U2" : {
  "1RXDSJzSEXakxvNdM41Ae3nbHN72" : true
},
"m11EvlP19OSbEz8XYl2MsNCwGXX2" : {
  "1RXDSJzSEXakxvNdM41Ae3nbHN72" : true
}
 },

"Users" : {
  "1RXDSJzSEXakxvNdM41Ae3nbHN72" : {
  "email" : "*@gmail.com",
  "name" : "Алексей Гвоздицкий",
  "picture" : "*.jpg"
 },
"NuKweeGv8zTgt1Vi9RcU3i1u86U2" : {
  "email" : "*@gmail.com",
  "name" : "Ольга Гвоздицкая",
  "picture" : "*.jpg"
},
"m11EvlP19OSbEz8XYl2MsNCwGXX2" : {
  "email" : "*@gmail.com",
  "name" : "Егор Александров",
  "picture" : "*.jpg"
 }
 }
}

I have a list of "events". Every "event" can be "forFiends" only (only if current user is in event creators "FriendsOF" list, then he can see this event. FriendsOF it's a whitelist). All availiable for current user events i want to represent in RecyclerView.

I am stucked. I can get all data snapshot and then filter on client side it. But it is not way of Jedi, because i load tonns of unnecessary data. Another solution is to deny acces to event if user should not see it. But i don't understand how to do it. My ref is mEventsRef = FirebaseDatabase.getInstance().getReference().child("Events").child("events"); And rule i can make for

"events":{ "$eventId":{".read":....} }

So according to this guide i'll get empty recyclerView because of "error callback triggered with PERMISSION_DENIED"

Help me to solve my problem please!

  • You've included a picture of the JSON tree in your question. Please replace that with the actual JSON as text, which you can easily get by clicking the Export button in your Firebase Database console. Having the JSON as text makes it searchable, allows us to easily use it to test with your actual data and use it in our answer and in general is just a Good Thing to do. – Frank van Puffelen Nov 21 '16 at 19:11
  • Aside from that: you seem to want to use security rules to filter data for a specific user, which is not possible. See [rules are not filters](https://firebase.google.com/docs/database/security/securing-data#rules_are_not_filters) in the docs or one of the many answers, such as [this original one](http://stackoverflow.com/a/14298525/209103). – Frank van Puffelen Nov 21 '16 at 19:13
  • @FrankvanPuffelen sadly it doesn't make life easier. Looks like I should replace the spark plug through exhaust pipe.. – Алексей Гвоздицкий Nov 22 '16 at 06:14
  • 1
    If you come from a background with relational databases, you're likely to find NoSQL databases "a bit limited". They are limited for good reasons, but that doesn't mean it won't take getting used to. I highly recommend reading this article on [NoSQL data modeling](https://highlyscalable.wordpress.com/2012/03/01/nosql-data-modeling-techniques/) and our new video series [Firebase for SQL developers](https://www.youtube.com/playlist?list=PLl-K7zZEsYLlP-k-RKFa7RyNPa9_wCH2s). – Frank van Puffelen Nov 22 '16 at 15:52

0 Answers0