question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clear items from DataStore which are no longer included in selective sync expression

See original GitHub issue

Is 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:open
  • Created 3 years ago
  • Reactions:7
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
iartemievcommented, Nov 9, 2020

Hey @mlxyz, we’re currently looking into ways of accomplishing this. Will keep this issue updated with any developments!

2reactions
mlxyzcommented, Jan 10, 2021

@mir1198yusuf Yes, that’s basically it. Even a way to clear individual items from DataStore only by id would suffice.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DataStore - Syncing data to cloud - JavaScript - Amplify Docs
Sync expressions get evaluated whenever DataStore starts. In order to have your expressions reevaluated, you can execute DataStore.clear() or DataStore.stop() ...
Read more >
Amplify DataStore best practices - AWS Documentation
Developers can do this by calling the DataStore.clear() API method. ... Manually forcing a synchronization with the backend is not possible.
Read more >
Download selective data from DataStore based on sub id ...
Although the Amplify.configure() is called once, but each time you do datastore start, your syncExpression function gets reevaluated.
Read more >
Copy and transform data to and from SQL Server - Azure Data ...
This integration runtime is used to connect to the data store. Learn more from Prerequisites section. If not specified, the default Azure ...
Read more >
Remove Virtual Machines from the Datastore - VMware Docs
If you no longer need a virtual machine and want to free up space on the datastore, you can remove the virtual machine...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found