What's the best way to automatically update data in a collection based on update in other collection
- 1
- Databases
- Functions
- Web
- Realtime

My project is similar to an e-commerce app. I have a like functionality. every user can see their liked products in their wishlist and every product has the count of how many users have liked it. For the wishlist, I have a users collection where there's a document for every user with the id same as the user id and it has only one attribute which is an array that contains ids of all the products a user has liked. For the Likes count, the products collection has a likes attribute which is an array that contains ids of all the users that has liked the product.
Earlier i was updating both collections whenever a user adds or removes a product from wishlist (i.e. likes or unlikes) but soon i realised that updating product data manually isn't a good idea since it'll have a concurrency problem. So i used appwrite relationships. now whenever i update data in users collection, it automatically updates the products data coz it's a two way many to many collection. But now i have a new problem. now the Arrays don't just have the ids but they have the whole objects. eg. the array in products collection returns all the attributes of the user with associated id and same thing with the users array. as the users and products grow, the size increased and now the requests are very slow. like it takes almost 10 seconds to load the products data which was almost instantaneous earlier.
Is there a way to only add user ids of the users who liked the products instead of adding their whole document? or even a way to just increase or decrease a likes count based on updates in the users collection? please help. Sorry for the long message, I thought I should make the situation clear.
Recommended threads
- my database attribute stuck in processin...
when i created attributes in collection 3 of those attributes become "processing", and they are not updating, the worst thing is that i cant even delete them s...
- Is Quick Start for function creation wor...
I am trying to create a Node.js function using the Quick Start feature. It fails and tells me that it could not locate the package.json file. Isn't Quick Start ...
- Forever Processing Issue
I encountered an issue when creating attributes in the collections . if you create an attribute of type string for example and choose a size of 200 or 250 or a...
