目前我在3step of the meteor tutorial我堅持流星教程第3頁2015年4月16日
第一次失敗是這樣的命令:
meteor mongo
據谷歌稱該命令現在由於失敗一個已知的錯誤。
所以,我解決它用這個命令:
mongo --port 3001
接下來,我從蒙戈提示試過此命令:
[email protected]:~/mets/simple-todos $
[email protected]:~/mets/simple-todos $
[email protected]:~/mets/simple-todos $ mongo --port 3001
MongoDB shell version: 2.6.7
connecting to: 127.0.0.1:3001/test
meteor:PRIMARY>
meteor:PRIMARY> db.tasks.insert({ text: "Hello world!", createdAt: new Date() });
WriteResult({ "nInserted" : 1 })
meteor:PRIMARY>
meteor:PRIMARY>
按照教程,我現在應該看到一個任務模板。
但是,我什麼都看不到。
JAVASCRIPT
// simple-todos.js
Tasks = new Mongo.Collection("tasks");
if (Meteor.isClient) {
// This code only runs on the client
Template.body.helpers({
tasks: function() {
return Tasks.find({});
}
});
}
HTML
<head>
<title>Todo List</title>
</head>
<body>
<div class="container">
<header>
<h1>Todo List</h1>
</header>
<ul>
{{#each tasks}}
{{> task}}
{{/each}}
</ul>
</div>
</body>
<template name="task">
<li>{{text}}</li>
</template>
'Tasks.findOne'或'Tasks.find()取()'你會得到什麼?該任務是否真的插入到集合中? – Ethaan
也可以在mongo控制檯中嘗試:'db.tasks.findOne()' –
@ user3676943請注意,爲了使'meteor mongo'工作,'meteor'必須仍然在另一個終端上運行。 –