在feathersjs文档中,提供的解释如下:
pluck丢弃除指定字段之外的所有字段 提交的数据或结果。如果数据是数组或 分页查找结果钩子将删除每个字段 项目
import _pluck from '../common/_pluck';
import checkContextIf from './check-context-if';
import getItems from './get-items';
import replaceItems from './replace-items';
export default function (...fieldNames) {
return context => {
checkContextIf(context, 'before', ['create', 'update', 'patch'], 'pluck');
if(context.params.provider) {
replaceItems(context, _pluck(getItems(context), fieldNames));
}
return context;
};
}
getItems实用程序返回hook.data或中的项目 hook.result取决于钩子是用作之前还是 钩后。为find找到hook.result.data或hook.result 方法。
返回的项目始终是一个数组,以简化进一步处理。
replaceItems实用程序与getItems相反,返回 他们来自哪里的物品。
我的问题与checkContextIf函数有关。此函数可防止在创建,更新和修补方法之前调用拔钩。然后,pluck hook如何处理查询结果。服务调用后产生的结果不是在挂钩后处理的吗?