I am currently working to write an aggregation query to pull data. We have a collection that has a subfield that can group multiple records together. An example would be we have a list of users that all have a unique "_id" field. All those users can be grouped into an organization and each organization has a unique id for it as well '_organization.id'.
I am working to write an aggregation query that takes all the distinct ‘_organization.id’ records that are missing a specific field we will say ‘email’. and seeing which ‘_organization_id’ records have more then one user linked to that ‘_organization.id’
I am having issues writing this up utilizing the $group statement.
Hey Josh, it would be beneficial to see sample documents and the expected output that you are looking for. With that we can better help write a query to do what you want. Without it, we’re just making assumptions which is generally not a good thing to do.