My website model contains Products. Each User is able to star, comment, mark, follow, put in a cart several products. So there is buttons on the right side for such actions:
oo Follow ☆ Star + Add to cart
So when the mod is being followed, starred and "carted" by the user, it gives me this:
✓ Following ★ Unstar X Remove from cart
The follow button is determined by a model Subscription
that contains an array of product ids being followed per user (on doc/user). The stars are in a model called Star
, a document per star (with a timestamp). The cart in a model with its name.
How to update the button label efficiently without killing performance? Of course I could make db requests while loading the product but that would kill performance :/