coresmart / persistencejs

persistence.js is an asynchronous Javascript database mapper library. You can use it in the browser, as well on the server (and you can share data models between them).
http://persistencejs.org
1.73k stars 240 forks source link

"In-Memory" in persistence.js not working #198

Open carper7 opened 3 years ago

carper7 commented 3 years ago

Hi,

I am looking for a tool that will allow me to store data in local storage and came across persistence.js. I am looking at being able to store the data, create a dump and then restore it to keep working on the same. Based on the github page this plugin allows to do that and more but I am having hard time making it work. I just played with the examples in the github but nothing is created and also get errors when dumping/restoring data. This is what I have so far:

persistence.schemaSync(); var Item = persistence.define('Item', { ItemId: "TEXT", Name: "TEXT" });

var item = new Item(); item.ItemId = "124"; item.Name = "Test1";

persistence.add(item); persistence.flush( );

persistence.dump(tx, [Item], function(dump) { console.log(dump); });

persistence.load(tx, dump, function() { alert('Dump restored!'); });

Could you please help me out. I would like to store some data in a json file, save it in local storage, create a dump of that json file, and finally restore it in order to keep adding more to it at a later time. These are the libraries I am using in my html file:

Kind Regards,

C.Peretz