【发布时间】:2018-08-29 13:23:47
【问题描述】:
当从规范化数据中删除一个实体时,我们如何处理删除被删除实体拥有的其他实体?比如下面的归一化数据,如果我要删除user1,我也要删除user1发的所有帖子和cmets。对于这种情况,是否有任何已知的方法或最佳做法?
{
posts : {
byId : {
"post1" : {
id : "post1",
author : "user1",
body : "......",
comments : ["comment1", "comment2"]
}
},
allIds : ["post1"]
},
comments : {
byId : {
"comment1" : {
id : "comment1",
author : "user1",
comment : ".....",
},
"comment2" : {
id : "comment2",
author : "user1",
comment : ".....",
},
},
allIds : ["comment1", "comment2"]
},
users : {
byId : {
"user1" : {
username : "user1",
name : "User 1",
}
},
allIds : ["user1"]
}
}
【问题讨论】:
-
尝试为此使用normalized-reducer
标签: reactjs redux normalization