Sean Ragsdale Sean Ragsdale - 1 year ago 61
Javascript Question

Return single value from a collection document in Meteor

I am trying to retrieve a single value from a Meteor collection document to use in a three.js scene. I want to be able to create a three.js object that uses variables from the database. These variables are static for now.

What I have is a three.js scene in Template.home.rendered. I have created a "Part" collection and made all data available to both client and server. There is a single data fixture (document) with

Part.insert({ name: "myPart", val: 75 });

I would like to able to return the value of the "val" field as a variable in the three.js scene like such
var size = Part.findOne(Part.val);
. However, the variable returns undefined. The data has been successfully written to the database and the browser cache. What am I missing?

Answer Source
size = Part.findOne({name:"myPart"}).val;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download