gpt4 book ai didi

javascript - 过滤 OrionJS 中某个 Angular 色可以查看的文档

转载 作者:行者123 更新时间:2023-11-28 06:25:11 25 4
gpt4 key购买 nike

如果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
}
});

关于javascript - 过滤 OrionJS 中某个 Angular 色可以查看的文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35184313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com