I want to delete the yellow user in the screenshot if he decides to delete his account. The blue X is a different user. How do I do that?
In the second picture is my attempt. I don't know how to get the userid of the blue X.
I want to delete the yellow user in the screenshot if he decides to delete his account. The blue X is a different user. How do I do that?
In the second picture is my attempt. I don't know how to get the userid of the blue X.
Your current data structure makes it easy to find the yellow Followers
for a given blue Follow
node. It does not however make it easy to find the blue node for a given yellow one. In fact, to allow that you will have to read all blue nodes, and check each individual Followers
child node in turn.
To more easily allow your use-case, you'll want to also store the inverse data structure that allows you to find the blue Follow
nodes for a given yellow Follower
value. I typically refer to this as the Followee
map, although I admit I'm not sure if that's even a word:
Followees: {
"ky....Yhi1": {
"L5w...6rF3": true
}
}
Now with this structure, you can find the "L5w...6rF3" key based on knowing the "ky....Yhi1" value and delete the user from the Followers
node there.
We covered this scenario a few times before, so I recommend also checking out: