Reputation: 3318
I'm looking for to return all exercices who contains a specific muscles group reference.
I tried this :
val db = FirebaseFirestore.getInstance()
db.collection("exercises")
.whereEqualTo("musclesGroups.hgMweNPXXXXXXXXX", true)
.addSnapshotListener({ value, e ->
Log.i("test", "Exercises " + value.documents.size)
})
But there is no result and no error, and size is 0
.
Upvotes: 0
Views: 42
Reputation: 599601
There is no way to query for whether a certain value exists in an array. Have a look at the Firebase documentation on working with arrays, lists , and sets for an alternative data structure that allows you to meet your goals.
It looks like your query already comes from there, but your data structure doesn't follow the model outlined in that solution. To write the proper structure the documentation uses a Map
with the values you want to filter for in the key, and true
in the value:
Map<String, Boolean> categories = new HashMap<>(); categories.put("technology", true); categories.put("opinion", true); categories.put("cats", true); MapPost myMapPost = new MapPost("My great post", categories);
Upvotes: 2