如果myRole.helper('collections.myCollection.indexFilter', {});
允许查看所有文档,如何将其限制为仅由用户创建的文档?我关注OrionJS documentation,其中有一个例子:
/**
* Set the index filter.
* This part is very important and sometimes is forgotten.
* Here you must specify which documents the role will be able to see in the index route
*/
myRole.helper('collections.myCollection.indexFilter', {}); // Allows the role to se all documents
此示例显示myRole
的所有文档,但我想将其限制为仅由它们创建的文档。我试过myRole.helper('collections.myCollection.indexFilter', { createdBy: this.userId });
,但没有显示任何文件。我确实创建了一些文档,其用户属于myRole
(并且createdBy
密钥确实存在),我确实看到过滤器关闭时,那可能是什么错误?
答案 0 :(得分:0)
想出来 - 过滤器需要是一个功能:
myRole.helper('collections.myCollection.indexFilter', function() {
return {
createdBy: this.userId
}
});