【发布时间】:2017-10-16 23:06:48
【问题描述】:
我有一个 Meteor 项目,我正在使用审计参数检查。我收到一条错误消息
Error: Did not check() all arguments during publisher 'document
我知道这与 audit-argument-check 无法检查所有参数有关。但就我而言,我检查了所有这些。具体来说,我已经定义了一个集合“文档”并附加了一个 SimpleSchema。作为 Iron-router 的一部分,我有以下内容:
Router.route('customerDocumentShow', {
template: 'customerDocumentShow',
path: 'customer/documents/:_id',
waitOn: function () {
return Meteor.subscribe('document', this.params._id);
},
data: function () {
return Documents.findOne(this.params._id);
}
});
所以我只传递了 documentId (this.params._id)。在服务器上,我定义了一个方法:
Meteor.methods({
documentsReadMethod: function(documentId){
check(documentId, String);
var documentItem = Document.findOne(argument);
if (!documentItem) {
throw new Meteor.Error(500, 'Error 500: Not Found', 'No documents found.');
}
return documentItem;
}
});
所以我在服务器方法中检查 documentId。所以不知道为什么我会收到此错误消息。
注意:我不完全确定的一件事是我需要如何调用此方法(现在是documentsReadMethod_。我没有明确调用(在客户端上):
Meteor.call(documentsReadMethod, this.params_id);
因为我使用的是 autoform、collection2 和 simpleschema。我已经度过了整个周末,但没有任何线索。有什么想法吗?
注意:代码在github上:https://github.com/wymedia/meteor-starter-base
【问题讨论】:
标签: meteor