@ ngrx / entities适配器-删除实体并使用此类更改更新相对实体

问题描述

@ nfrx / entity适配器是否具有这种功能? 假设我有2个实体:用户和帖子:

users = {
  'id1': {
   id: id1,name: user1,posts: [1,2,3]
 }  
}

posts = {
  1: {
    id: 1,userId: id1
  },2: {
    id: 2,3: {
    id: 3,userId: id1
  }
}

当我删除帖子时:

adaptor.removeOne(action.payload.id,state)

但是此行仅从帖子中删除实体,但已删除帖子的ID保留在user.posts数组中

是否可以根据帖子实体的操作来更新user.post?有一个动作吗?

现在我有两个动作:

  1. 删除帖子
  2. 从user.posts数组中删除相关的postId

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)