在 OrionJS 中过滤文档以供特定角色查看

Filter documents to be seen by a certain Role in OrionJS

如果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 密钥确实存在),当过滤器关闭时我确实看到了,所以可能是什么问题?

明白了 - 过滤器需要是一个函数:

myRole.helper('collections.myCollection.indexFilter', function() {
  return {
    createdBy: this.userId
  }
});