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
- Scheduled works locking the entire Maria...
I have a scheduled function and apparently that or something is locking the entire MariaDB database and Appwrite is giving MariaDB errors. This error persists e...
- Need help to create a wrapper which let ...
I’m looking for help setting up Appwrite properly on a VPS so I can build a self-hosting wrapper around it. The goal is to provide a Linux executable that allow...
- Use Limits
I need urgent help, i use appwrite as a chat function for my website and my mobile android application, but recently, for the past 3 months, my database reaches...