aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.32k stars 247 forks source link

DataStore delete only user specific data on user signing out, and preserve other data in local DataStore #2528

Open ruossn opened 1 year ago

ruossn commented 1 year ago

We have user specific data, and data that are for all users the same. We want to use Datastore to synchronize them from the backend, the app does not change data. If the user log out, we need to delete the user spesific data, because of the General Data Protection Regulation from the EU. But because of offline functionality, also after the logout and, we need to delete only the user data, the general data for all useres must still be availible. Is there a way to delete the data only locally and synchronize it again after a new login, or reevaluate the filter and delete not includetet data? If this is currently not supported, is it possible to implement it?

HuiSF commented 1 year ago

Hi @ruossn thanks for posting this question. Amplify DataStore plugin provides an API, clear, which allows to clear all local data, which is recommended to invoke on user signing out, you can do this by listening to auth event (see example here) in your App.

Please let us know if this is not sufficient for your use case.

ruossn commented 1 year ago

Hi @HuiSF, thanks for your fast response. I know the clear method, but then all data is deleted. And to synchronize it i need network connection and the complete data must be downloaded again. Or am i wrong? We need to clear only the user specific data. We have large data that still has to be availible after the logout, even if the phone is offline.

HuiSF commented 1 year ago

Hi @ruossn thanks for following up, now I understood your use case better. And you are correct regarding the behavior of the clear API.

I don't think the DataStore plugin currently provides a functionality to support this use case. I think below points need to be fulfilled for this:

I will mark this issue as a feature request.

We have large data that still has to be available after the logout

Could you give more details about the large data? E.g. is it expected to be mutated by the user or it's static

rangershi commented 1 year ago

the same problem for me . I have some data store in Datastore,some of them need sync to could ,some of them not(large data), but when i sync to cloud ,all the data send to the could. I advise add a new annotation to mark the model which indicate the model is only loacl data, when sync to cloud skip all the marked model , that perfect ! @HuiSF

ruossn commented 1 year ago

Sorry @HuiSF for the late response.

The shared data for all users is only changed by the backend, not by the users. The users can only change some of the user specific data, and these changes must be synced.

What we need, is to resynchronize the user data with the new user, without loosing the other data localy.

@rangershi as i understand your point, this is a different usecase, we want to synchronize all data, but we want to clear only the user data on logout. I think you can already implement your case with the (syncExpressions ).

rangershi commented 1 year ago

@ruossn thank you