Access one item in collection


My database looks like this:

{ “_id” : “ceg9JJ3u5abwqeyk7”, “board” : [ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ] }

I want to be able to access the value of just one zero and place it in my template.
I think I need to access the database in my helper.js . This is my helper code:
counter() {
return Template.instance().counter.get();
game() {
console.log(“inside game helper2”, Games.find());
console.log(“inside game helper3”, Games.findOne());
if (Games.findOne()) {
console.log(“inside game helper6”);
let testvar = Games.findOne();
console.log(“inside game helper7”, testvar);
console.log(“inside game helper8”, this.prop.testvar)
else {null}
return Games.find()
I think I need to use “this.prop.testvar” variable to access different elements inside Game.findOne(). But this line gives me an “undefined” exception even though the “testvar” in the above line is fine. I also tried sending Games.find() to the template, but it sends a complete document and I don’t know how to parse it. I also tried naming values inside the database, but got errors doing that.

I’ve tried all sorts of things, but I’m afraid I’m lost. Any help?



I am not sure you are subscribing to your data or you have the autopublish package… also, ensure you put your code inside ``` lines when posting so that we can read it…


My apologies. I was way off base in a whole bunch of ways. this.prop.testvar is a react command apparently, which I’m trying to use in a blaze template. Plus, my board array is only one key/value pair, which is why #each only cycles through it once. Also, I realized that the database structure isn’t what I wanted any ways. In explanation, I was working off hiukim’s multiplayer tutorial, which I was trying to extend without really understanding the react part of it. Thanks for trying to help.