How can I project an object only if document has a specific field in MongoDB?
I have the following project: { '$project': { '_id': 1, 'applicationIds': { 'type': 'linux', 'refId': '$applicationIds' }, 'configurationIds': { 'type': 'linux', 'refId': '$configurationIds' } } } As long as there is at least one record in $configurationIds I will get…