Okay, so I have an object with a list of Firebase users within it which i've been able to create the object, the problem I'm having is the nested object need information from elsewhere in the database. how would i go about retrieving data for each child node and return one object with the nested object? below is the database structure with a better explanation and some code
https://i.stack.imgur.com/OPgAH.png
so, in -(Collabs) > (User_uid) each push id is an Object and for each 'User' in (Artists) I need to retrieve an image from -(Users) > (User_uid) > (image) and return one object. Apologies in advanced if this seems a bit ignorant, as I'm still a little new to this. thank you!
public void getAllCollabs() {
FirebaseUser current_user = auth.getCurrentUser();
String current_uid = current_user.getUid();
DatabaseReference db_collabs = db_root.child("Collabs").child(current_uid);
final ArrayList<Collab> collabs = new ArrayList<>();
Query collab_query = db_collabs.orderByKey();
collab_query.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
ArrayList<String> artists = new ArrayList<>();
String title = dataSnapshot.child("mTitle").getValue().toString();
String content = dataSnapshot.child("mContent").getValue().toString();
Long date_time = dataSnapshot.child("mDateTime").getValue(Long.class);
String push_id = dataSnapshot.child("push_id").getValue().toString();
String creator = dataSnapshot.child("creator").getValue().toString();
Iterable<DataSnapshot> collab_artists = dataSnapshot.child("Artists").getChildren();
for (DataSnapshot user : collab_artists) {
artists.add(user.getKey())
}
Collab collab = new Collab(date_time, title, content, creator, push_id, null);
collabs.add(collab);
loadCollabResults.collabsLoaded(collabs, true);
}