[英]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. 我试图从Meteor集合文档中检索单个值以在three.js场景中使用。 I want to be able to create a three.js object that uses variables from the database.
我希望能够创建一个使用数据库中的变量的three.js对象。 These variables are static for now.
这些变量现在是静态的。
What I have is a three.js scene in Template.home.rendered. 我所拥有的是Template.home.rendered中的three.js场景。 I have created a "Part" collection and made all data available to both client and server.
我创建了一个“Part”集合,并将所有数据提供给客户端和服务器。 There is a single data fixture (document) with
Part.insert({ name: "myPart", val: 75 });
有一个带有
Part.insert({ name: "myPart", val: 75 });
的单个数据夹具(文档) 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);
我希望能够将“val”字段的值作为变量返回到three.js场景中,如
var size = Part.findOne(Part.val);
. 。 However, the variable returns undefined.
但是,变量返回undefined。 The data has been successfully written to the database and the browser cache.
数据已成功写入数据库和浏览器缓存。 What am I missing?
我错过了什么?
size = Part.findOne({name:"myPart"}).val;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.