Skip to content

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

Description

@carper7

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:

<script src='persistencejs/lib/persistence.js'></script>
<script src='persistencejs/lib/persistence.store.memory.js'></script>

<script src='persistencejs/lib/persistence.store.sql.js'></script> <script src='persistencejs/lib/persistence.store.websql.js'></script>

Kind Regards,

C.Peretz

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions