0

I want to get to "sid" in order to put it in query "firebase" But I don't know how to get there because orders "model" with the increase in orders, it increases from 1 to ...

enter image description here

I tried it this way but it didn't work and this is because of "0" number of orders

 String currentuser = FirebaseAuth.getInstance( ).getCurrentUser( ).getUid( );
 FirebaseDatabase database = FirebaseDatabase.getInstance( );
 DatabaseReference root = database.getReference( "Requests" );
 Query   query = root.orderByChild( "orders/sid" ).equalTo(currentuser  );

enter image description here

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

1

Firebase RTDB does not support this kind of query. Firestore might and obviously sql does. In a NoSQL db you really need to duplicate some data in order to satisfy your queries. This also means you need to maintain data integrity 'manually'. In this example I would suggest you need to maintain another node that is keyed by 'sid' ids and that lists the numbers of the orders that they are associated with. Otherwise, you will need to download all the relevant orders as a snapshot and iterate through them in your app.

GrahamD
  • 2,952
  • 3
  • 15
  • 26