am developing an ecommerce ive created an appwrite collection for favorites. i fetch it when the user logs in but i dont want to upload a list everytime a user likes a product i want to upload once when user minimizes or closes the app or logs out so that to reduce number of uploads. Whats the best way to handle favorites?
Store the favs. locally, use something like a workmanager to upload later.
Is a favourited item a record in the collection or it's an entry in an array? If the latter is true, would making each favourited item a record pose a problem? IMO having each item as a record makes additions/deletions easier.
If it would be an array, this "could" cause issues later maybe since the list would grow and grow at some point. A better way would be to keep user specific documents for their favs & set permissions to that user only. A function could be used, something like WorkManager works fine as well in this case.
Yes! That's how I would approach it too. I wouldn't bet on 100% write success when the app is exiting or being put in the background. Some OEM androids are aggressive with killing background tasks. Heck! I have deliberately turned on aggressive killing of background tasks for most apps on my phone
That's true. In my case, I use a text file for each user's record, and I store them in a specific storage bucket. This approach helps avoid potential issues with growing lists and allows for user-specific documents with permissions
Lemme look into it
So favorites as documents is better than favorites as an array
IMO yes. I would use an array for items that I know wouldn't would grow as much.
How much are considering like 50+ or 100+
I'd say 100+
Okay that's fine
For social media it's easier to exceed 100 for liked posts but like ecommerce I don't expect to exceed 100
Depends on the kind of ecommerce app. In any case, the main point is relying on the app closing or being put in the background to write to the DB is not ideal
Recommended threads
- Relation Question
How do I create a relation from table y to an others x.$id. in my example I have a users table where I use Appwrites unique User IDs and I want other tables fo...
- Unknown attribute type: varchar / text
Since the `string` type is deprecated I tried using `varchar` and `text` in some newer tables, but when running `appwrite pull tables && appwrite types ./src/li...
- I'm experiencing a critical bug on Appwr...
Hey <@870607367597850624> team / support 👋 I'm experiencing a critical bug on Appwrite Cloud that's blocking my production Flutter app. I've already filed GitH...