1

So when I want to write multiple values on different points on my Firebase database at the same time I use a HashMap. Here is an example:

 HashMap<String, Object> friendsMap = new HashMap<>();
 friendsMap.put("TABLE_1/" + currentUser.getUid() + "/" + displayingUser + "/date", currentDate);
 friendsMap.put("TABLE_1/" + displayingUser + "/" + currentUser.getUid() + "/date", currentDate);
 friendsMap.put("TABLE_2/" + currentUser.getUid() + "/" + displayingUser, null);
 friendsMap.put("TABLE_2/" + displayingUser + "/" + currentUser.getUid(), null); 

 mRootRef.updateChildren(unFriendMap,...);

Is there any way to achieve something similar with queries?

I can run them separately but I lose performance that way.

Query query = mRootRef.child("TABLE_1").orderByChild("some_value").equalTo("something");
Query query2 = mRootRef.child("TABLE_2").orderByChild("some_other_value").equalTo("something_else");
Vy Do
  • 46,709
  • 59
  • 215
  • 313
Nick Pampoukidis
  • 702
  • 8
  • 28
  • for update you do this to keep constancy of data , for reading data it deference case , so I think there is no way to achieve that – Ali Faris Jan 18 '18 at 13:26
  • 1
    Did you measure the performance already? How do you know it's caused by having multiple queries? Running multiple queries is not necessarily much slower than getting the same data in one go, since Firebase pipelines the requests to the database over a single connection. See my explanation [here](http://stackoverflow.com/questions/35931526/speed-up-fetching-posts-for-my-social-network-app-by-using-query-instead-of-obse/35932786#35932786). In my experience most of the performance implications come from the amount of data you're reading and the bandwidth of the client, not how you read it. – Frank van Puffelen Jan 18 '18 at 15:34

0 Answers0