Clear items from DataStore which are no longer included in selective sync expression
See original GitHub issueIs your feature request related to a problem? Please describe. When applying a more restrictive selective sync expression for DataStore, the existing content of the local storage is retained (see https://docs.amplify.aws/lib/datastore/sync/q/platform/js#reevaluate-expressions-at-runtime). In our application, a portion of data items we sync with DataStore is newly generated every day and the sync expression only includes the items which are relevant for the current day. Without a way of clearing out “old” items which are no longer included in the sync expressions, the local storage of clients will grow indefinitely over time impacting performance and user experience.
Describe the solution you’d like We would be fine with either of these solutions:
- DataStore automatically clears items from local storage which are no longer included in a sync expression.
- Allow developers to manually remove items from the DataStore (by id or using a selective expression) without deleting them from DynamoDB.
Describe alternatives you’ve considered
We have considered calling DataStore.clear()
to remove old content when changing the sync expressions (as mentioned in the documentation), but this is inefficient as DataStore then also has to resync data items which should be retained over longer time periods.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:7 (1 by maintainers)
Top GitHub Comments
Hey @mlxyz, we’re currently looking into ways of accomplishing this. Will keep this issue updated with any developments!
@mir1198yusuf Yes, that’s basically it. Even a way to clear individual items from DataStore only by id would suffice.