data assossiations

8 views
Skip to first unread message

Hadi H.

unread,
May 13, 2018, 8:49:51 PM5/13/18
to mongodb-user
Hi everyone,
i have built an app that has data associations, and for example it has a collection named Posts and a collection named Comments. they are associated to each other. in data association _id in stored. i want to see the whole data not just the _id of the associated data in mongo compass and the mongo shell. Is there any way to do that? Tnx in advance

Wan Bachtiar

unread,
May 16, 2018, 1:46:06 AM5/16/18
to mongodb-user

in data association _id in stored. i want to see the whole data not just the _id of the associated data

Hi Hadi,

You can utilise MongoDB Aggregation Pipeline to perform a left outer join using $lookup stage based on the ‘associated’ field. i.e. _id.

If you have further question, please provide:

  • MongoDB version
  • Example documents
  • Desired output that you have in mind.

Regards,
Wan.

Reply all
Reply to author
Forward
0 new messages