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
- Apple OAuth Scopes
Hi Hi, I've configured sign in with apple and this is the response i'm getting from apple once i've signed in. I cant find anywhere I set scopes. I remember se...
- Sign In With Apple OAuth Help
Hi All! I've got a flutter & appwrite app which Im trying to use sign in with apple for. I already have sign in with google working and the function is the sam...
- Type Mismatch in AppwriteException
There is a discrepancy in the TypeScript type definitions for AppwriteException. The response property is defined as a string in the type definitions, but in pr...