【发布时间】:2015-11-16 10:45:08
【问题描述】:
我正在学习node和mongodb
我的应用运行良好(它是在线教程应用)
我有两个问题
// define model =================
var Todo = mongoose.model('Todo', {
text : String
});
// create todo and send back all todos after creation
app.post('/api/todos', function(req, res) {
// create a todo, information comes from AJAX request from Angular
Todo.create({
text : req.body.text,
done : false
}, function(err, todo) {
if (err)
res.send(err);
// get and return all the todos after you create another
Todo.find(function(err, todos) {
if (err)
res.send(err)
res.json(todos);
});
});
});
我希望你能理解我的代码(它的待办事项添加应用程序)
1) 'Todo' 是 mongoDB 中的集合吗?
我输入了 cmd db.collection.find() 但没有任何结果? , 我在cmd上使用哪个命令来查看这里的数据
2) 我可以用任何工具在我的编辑器中打开数据库数据存储文件吗?
【问题讨论】:
标签: javascript node.js mongodb