I am beginner to MongoDB and I have Photo, Video ,Friend and User collection in mongoDB.
I am implementing search by name functionality, where i need to display user with his number of friends, number of photos and number of videos.
Right now, what i do is i execute find query on user collection and get user objects/documents.
Then i execute for loop through search result and for each user i get number of friends, photos and videos using individual queries as MongoDB doesn't support join.
To get rid of this for loop i am planning to embed friend id, photo id and video id into user object/document as below
@Document
Class User {
   List<String> friendIds;
   List<String> phtotIds;
   List<String> videoIds;
}
Is this correct way or is there any better solution?
Please guide.
Thanks
 
    