Okay, I have a collection in MongoDB for a meteor project. A document is too long to post here so I'm just going to put in an example of a document in the collection to get my point across:
_id: "RxBqDLxxPG89ngp9d",
name: "deck of cards",
deck: [
{
suit: "spades",
value: "ace",
},
{
suit: "spades",
value: "king",
},
{
suit: "spades",
value: "queen",
},
{
suit: "hearts",
value: "ace",
},
{
suit: "hearts",
value: "king",
},
{
suit: "hearts",
value: "queen",
}
]
(one can assume that I did the whole deck, but it doesn't matter for the purposes of the example) And so I know that if I wanted to get names of all of those on a page I would have to write a helper in whatever template I'm working with.
"displayCards": function(){ return deckOfCards.find().deck; }
And then in the html of the helper:
{{#each displayCards}}
<div class="card">{{value}} of {{suit}}</div>
{{/each}}
Which will return:
ace of spades
king of spades
queen of spades
ace of hearts
king of hearts
queen of hearts
So here is where I finally get to my question:
I want to put a div with a class of suit around each suit of cards. To do this I need to be able to either return an array of just the elements where the suit is equal to hearts or spades, etc. OR I need to be able to return a piece of the array 13 (or two, if we are just going by what I have written) cards at a time. Is there a way to do this?