Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Architect insta_users collection for better performance #56

Open
GustavoContreiras opened this issue May 23, 2019 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@GustavoContreiras
Copy link
Contributor

GustavoContreiras commented May 23, 2019

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.

@mdanics
Copy link
Owner

mdanics commented May 23, 2019

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...

@mdanics mdanics added the enhancement New feature or request label Jun 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants