Project only 1 element in an array

Hello, I have a query and I need to project certain fields, _id, CustomerId and then an element in an array. The CardType Element in the PaymentMethod array.

{_id: 1, CustomerID: 1, PaymentMethod.CardType: 1}

Dot notation doesnt seem to work for this. Any direction would be greatly appreciated thanks

I figured it out thank you. I still cant figure out how to delete a thread though lol

Please share what was the issue so that others do not fall in the same trap.

Sorry about that Steeve. So I was using
{_id: 1, CustomerID: 1, PaymentMethod.CardType: 1} and I shouldve been using
{_id: 1, CustomerID: 1, “PaymentMethod.CardType”: 1} was just missing quotes

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.