-
Notifications
You must be signed in to change notification settings - Fork 286
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
Data Persistence #146
Comments
You can serialize and store Taffy data using var db_fn, record_list, json_str;
db_fn = TAFFY( [ { name : 'fred' } ] );
record_list = db_fn().get();
json_str = JSON.stringify( record_list );
localStorage.setItem( 'my_taffy_key', json_str ) ); And then to retrieve: var json_str, record_list, db_fn;
json_str = localStorage.getItem( 'my_taffy_key' );
record_list = JSON.parse( json_str );
db_fn = TAFFY( record_list ); Please confirm if this works for you. I propose to add this to the README and then close. |
@acefxlabs is this answer working for you? Please confirm and we can resolve the issue. |
Hi!.. i'm not acefxlabs... but it worked for me!.. |
Related to this, I need to write an adapter to write persistent data to filesystem. Are there any examples of this type of persistence I can use as a model or am I starting from scratch here? Any thoughts on whether this is practical ... and wise? ;) Use case: I am building an embedded server that must handle a modest number of records with persistence but is light on resources (ie. not enough for sqlite). I plan to persist records as JSON (actually YAML) files the filesystem. So I need to initially populate the records into a taffy db on server start up, and then dump records to YAML @filesystem on store(). I also need to store one-to-many child data records under the parent (as streams) because there may be thousands of records in some cases. Any hints, tips, thoughts, gotchas? |
To anyone else trying this code, make sure you remove that last closing parenthesis on the setItem line. That typo wasted 10 mins of my life 💃 |
Is there a way to make TaffyDB data persistent so it can stay even onreload of page
The text was updated successfully, but these errors were encountered: