I have a processes document with a nested attachments array, I want to return get the fileName with the processes _id and attachment _id.
I have tried many options, my latest attempt still return all items from the attachments array. I only want the attachment that matches the attachment id past in.
db.getCollection('processes').find(
{$and: [ { "_id" : ObjectId("5a9455d7854cd987a40b1ba4") },
{ "attachments._id" : ObjectId("5a983da6201ba5a2302fb38f") }]},
{'attachments._id': 1, 'attachments.fileName': 1}
)
Any suggestion is greatly appreciated, thanks!
