How can I read all objects within another collection (nested)? The documents were created with a random number (UUID).
USER(Collection)->UUID(Doc)-->OBJECTS(Collection)->UUID(doc)->Object
db.collection("USER").document(//RANDOM UUID).collection("Objekte").get().addOnSuccessListener{ result->
listHouses = ArrayList()
progressDialog.dismiss()
for(document in result.documents)
{
val house = document.toObject(Houses::class.java)
listHouses.add(house!!)
}
var viewPager2 = view?.findViewById<ViewPager2>(R.id.viewPagerHome)
myAdapter = CustomAdapter(myCtx,listHouses)
viewPager2?.adapter = myAdapter
}
}
CodePudding user response:
If you want to read the Objekte
of a specific user, you will need to know the document ID of that user.
If you want to read the Objekte
across all users (and even across the entire database), you can use a collection group query. Based on that documentation, it'd be something like:
db.collectionGroup("Objekte").get().addOnSuccessListener{ result->
// ...
}