Architect insta_users collection for better performance
GustavoContreiras opened this issue · 1 comments
Firestore.instance.document("insta_users/$profileId").updateData({
'followers.$currentUserId': true
//firestore plugin doesnt support deleting, so it must be nulled / falsed
});
Firestore.instance.document("insta_users/$currentUserId").updateData({
'following.$profileId': true
//firestore plugin doesnt support deleting, so it must be nulled / falsed
});
If each user (document) of the "insta_users" collection had inners collections called "followers" and "followings" that contains a string with the id of the user you are following/being followed, you could delete them instead of setting null.
I know this project wasn't designed for millions of users and probably you won't change it (because it needs to recode many things) but I think it's good to point this out.
Edit:
Or even better, you don't need a new inner collection, you could just keep a followersIds field that holds a List of String and a followingsIds field that holds a List of String too and everytime the list change you recreate it and send the entire list again.
Anyway, I don't know if I'm right. Just thinking that this thing of setting null because you cant delete is a little weird.
Yes you are right. At the time of writing Fluttergram the firebase plugin did not have deletion support so this was a workaround.
Now the plugin does support it, it would make sense to rearchitect it but I'm not sure if that is something I will have time for...