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
- MariaDB refuses to connect to appwrite
Earlier, I tried updating my Appwrite version from 18.1.x to the latest release because my Flutter package required it to function properly. I used the official...
- executeFunction intermittently throws Fo...
Environment: Flutter app using the Appwrite Flutter SDK, calling executeFunction for [describe endpoint, e.g. live-stream-related function]. *Description*: Int...
- Console display all Databases as TablesD...
While looking at an issue with <@1231860789355347971> we saw that the console was displaying ALL databases as `TablesDB` even if the real type in the API is `le...