I have this structure
Now, Im making a query like this:
DatabaseReference myRef = database.getReference("users");
myRef.equalTo("6991580","ci").addListenerForSingleValueEvent(new ...
I was expecting the second node as result.. Then I get:
DataSnapshot { key = users, value = null }
So, what is wrong with this query? or maybe Im doing something wrong?
Best regards and thanks for reply.
Firebase data is retrieved by either a one time call to GetValueAsync() or attaching to an event on a FirebaseDatabase reference. The event listener is called once for the initial state of the data and again anytime the data changes.
Cloud Firestore provides powerful query functionality for specifying which documents you want to retrieve from a collection or collection group. These queries can also be used with either get() or addSnapshotListener() , as described in Get Data and Get Realtime Updates.
addValueEventListener() keep listening to query or database reference it is attached to. But addListenerForSingleValueEvent() executes onDataChange method immediately and after executing that method once, it stops listening to the reference location it is attached to. Follow this answer to receive notifications.
To enable full text search of your Cloud Firestore data, use a dedicated third-party search service. These services provide advanced indexing and search capabilities far beyond what any simple database query can offer. Before continuing, research then choose one of the search providers below: Elastic.
You need to tell Firebase what child property you want to order/filter on:
myRef.orderByChild("ci").equalTo("6991580").addListenerForSingleValueEvent(...
The other format of ordering is a commonly misunderstood version. I'd recommend simply staying away from it.
I had the same problem and solve it by changing listener:
myRef.orderByChild("ci").equalTo("6991580").addChildEventListener(new ChildEventListener() {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With