I have following code in my router
Router.route('/guide/:_id', function () {
this.render('guide_detail', {
data: function () {
var guide = Guides.findOne({_id: this.params._id});
console.log("The cards of this guide are: ", guide.cards);
var cards = Cards.find({_id : guide.cards }).fetch();
console.log("Actually fetched cards: ", cards);
return {
guide: guide,
cards: cards
};
}
});
}, {name: 'guide_detail'});
When I console.log(guide.cards)
what is a list of ObjectId’s I receive the name of these cards. This is how my guide schema looks like at the moment.
GuideSchema = new SimpleSchema({
title: {
type: String,
label: "Title",
max: 200
},
isPublic: {
type: Boolean,
label: "Public"
},
cards: {
type: [String],
minCount: 0,
maxCount: 30,
label: "Cards"
... and some other stuff
I want to render the template and give the guides and the card objects that belong to this guide. My approach was to find the guide I want to give to the template and then search for the cards of the guide according to guides.cards
. Unfortunately this is not working properly and I wanted to ask you guys, how I am able to solve my problem. Is it somehow possible to receive the ID’s of the cards? Or is there even a better approach to do what I want to do?
In addition this is a card object from my database:
{ “_id” : ObjectId(“564c7fefef88adec793948f5”), “name” : “Leper Gnome”, “mana” : 1, “rarity” : “Common”, “dust” : 40, “cardClass” : “All”, “cardSet” : “Classic”, “cardType” : “Monster”, “imageUrl” : “/images/cards/LeperGnome.png”, “damage” : 2, “health” : 1 }