users user_ID user_name user_email user_password Groups - grupid 1 - grupid 2 - grupid 3 groups group_ID group_name group_description comments 1 - user_ID comment_txt 2 - user_ID comment_txt
If you are worried about the size of the comment (currently the maximum mongodb file size is 16 mb), you can move it to another document
This way you can find group users
db.users.find({Groups:'groupid1'})
also groups to which the user belongs
db.users.find({id:userid},{Groups:1})
if you want to get information related to a group with the above request, I suggest that you store the most frequently used group fields also with user groups, for example
users user_ID user_name user_email user_password Groups - { grupid 1,name} - {grupid 2,name} - {grupid 3,name}
RameshVel
source share