我有一个电话,我在其中获得了要提交的未完成报告的人员的 ID 列表,并且我想跟踪该人员未完成的报告的数量。我正在使用 EntityAdapter 存储该数据。现在我不知道如何在适配器中保持计数。
到目前为止,我已经检查了 ngrx 文档,尝试了很多对代码的操作,并在 gitter 聊天室问了我的问题,但到目前为止还没有结果。
我的服务返回一个字符串数组,其中包含人员的 id。示例数据可能是:
在这里,我有两次相同的 ID,这意味着该人有 2 份报告。我想存储该 ID 并保持计数“2”。目前我正在将此代码用于适配器:
export interface State extends EntityState<string> {
showRegistrations: boolean,
loading: boolean,
loaded: boolean,
}
export const adapter: EntityAdapter<string> = createEntityAdapter<string>({
selectId: (item: string) => item,
sortComparer: false,
});
export const initialState: State = adapter.getInitialState({
showRegistrations: true,
loading: false,
loaded: false,
});
这在我的商店中为我提供了以下结果:
但我实际上正在寻找以下结果,每个 Id 都存储在其中,并且我知道该 Id 被具体找到了多少次: