findOne()からオブジェクトを返して使用する方法を理解するのに問題があります。
私のコードはこれです:
HTML:
<head>
<title>count</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
{{showcount}}
</template>
Js:
var Database = new Meteor.Collection("counters");
if(Meteor.is_client) {
Template.hello.showcount = function () {
var c = Database.findOne();
return c;
};
}
if (Meteor.is_server) {
Meteor.startup(function () {
if(Database.find().count() === 0)
{
Database.insert({name: "counter", value: 0});
}
});
}
オブジェクトからデータにアクセスする方法があるかどうか疑問に思っています。{{showcount}}から{{showcount.name}}への変更はまったく機能していないようです。