我正在使用Mongo开始使用Sailsjs(特别是sails-mongo
包,遇到了一个介绍问题,我似乎找不到任何相关的文档。
基本上,我有一条路线:
module.exports.routes = {
'/': 'PagesController.index',
'/testing': 'PagesController.about'
}
另外,我有一个模型Websites
module.exports = {
connection: 'mongodb',
attributes: {
}
};
然后在我的控制器中,我执行以下操作:
Websites.find().done(function(err, response){
sails.log(response);
});
其中,给出了以下错误:
TypeError: Websites.find(...).done is not a function
N.B。在我的'connections.js'中,我有以下内容:
mongodb: {
adapter : 'sails-mongo',
host : 'localhost',
port : 27017,
database : 'SEO'
}
我在哪里遇到错误的想法?
答案 0 :(得分:1)
代码中的简单错误就是这样。
没有done
功能。您必须运行exec
Websites.find().exec(function(err, response){
sails.log(response);
});