I'm using TaffyDB to have a local/offline database
but unfortunately - after refreshing the browser tab - it loses the data
example: I have this initial variable
var clist = TAFFY();
onclick event on button - it execute this statement
clist.insert({"123" , count:count , color:color , size:size});
after clicking it - and reload the browser tab , I execute this statement
alert(clist({PID : "123"}).count());//output 0
however the previous statement should output 1
but unfortunately - after refreshing the browser tab - it loses the data
Well, yeah, that's how TaffyDB works.
however the previous statement should output 1
No, it shouldn't.
TaffyDB is in-memory only. As soon as the context for your script is torn down, such as on a page reload, it's gone. If you want to persist it, you have to do that yourself.
The easiest thing to do is serialize the entire dataset as JSON and shove it in localstorage
, provided it's small enough to fit there.