【发布时间】:2015-07-07 09:09:52
【问题描述】:
尝试使用具有数组的 Mongodb 集合。想在模板中使用数组。
Index.html
<body>
{{>test}}
</body>
<template name="test">
{{ #each task}}
<p>{{this}}</p>
{{/each}}
</template>
The app.js
Task= new Mongo.Collection("Tasks");
if (Meteor.isClient) {
// This code only runs on the client
Template.test.helpers({
task: function () {
return Tasks.find({"cat":"TASK"}, {"_id":0, "ALL_TASKS":1});
}
});
}
if (Meteor.isServer){
if (Task.find({}).count() === 0){
Task.insert({"cat":"TASK", "ALL_TASKS":["t1","t2"]})
}
}
它不起作用。我错过了什么
【问题讨论】:
标签: arrays mongodb templates meteor