Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to delete data from NV storage? #97

Open
kapso opened this issue Dec 29, 2013 · 4 comments
Open

How to delete data from NV storage? #97

kapso opened this issue Dec 29, 2013 · 4 comments

Comments

@kapso
Copy link

kapso commented Dec 29, 2013

Is there a way to delete data from NV storage after I have saved using Model.serialize_to_file

Looked around inside the code and the docs, cant find this info anywhere?

@sxross
Copy link
Owner

sxross commented Dec 29, 2013

Your app's data is deleted when your user removes the app. If you want to, you can remove the files using Ruby's File class methods on the persistent store.

@kapso
Copy link
Author

kapso commented Dec 29, 2013

Well I have a "logout" functionality which once clicked should remove the data from storage. Can you point me to the code where I can find the file path details?

@sxross
Copy link
Owner

sxross commented Dec 29, 2013

In the README here you can see that persistence to the sandbox is done by filename. When your user logs out, you can adopt one of several strategies:

  • Delete the data objects relevant to that user and then persist the object collection -or-
  • Delete all the data objects and then persist the object collection -or-
  • Use Ruby's File#delete to simply remove the file. Note this does not tell MotionModel that you are deleting the persistent data so you could re-serialize the in-memory version after removing the file and it would be as though you didn't delete it.

I recommend you remove the data using MotionModel's delete_all or destroy_all methods, then either serialize the model to persist the empty changes to the non-volatile store or you could use File#delete.

@sxross
Copy link
Owner

sxross commented Dec 30, 2013

I wrote a straw man that I think would solve your problem: https://github.com/sxross/MotionModel/wiki/Strategy-for-MotionModel-Persistence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants