works. The problem is that is returns the whole array, and I don’t know in advance which index I need to display ( [x] ). How do I return the array element which matches “cards.brand” : “cu7dN8yDK8Sx58isN” ?
Once you do Collection.findOne(), it just returns a regular Javascript object, so you should treat it like one. Let Mongo take care of the data fetching.
I didn’t realize you were doing it on the client side, my solution works only on the server side.
Minimongo (client side storage )doesn’t support $ operator.
So it ignores array filter in your query.
If supported, this would work on the clientside too!
testq.find({userId : “hFefx7scAPgcQFoDg” , “cards.brand” : “hFefx7scAPgcQFoDg” },{fields:{“cards.$”:1}}).fetch();
It’s rather easy to display a nested array in a template (just use #each). But it does take a little more work to isolate something in a nested array. In some cases it’s a lot nicer to store only arrays of _id Strings (as references) inside documents, instead of arrays of objects. Then store the contents in another collection. It depends on the use case though.