How can I create a client-side database that persist between sessions?

1.2k Views Asked by At

I'm working with HTML5 to create a client-side database using the Lawnchair Javascript library, but when y create a new Lawnchair object what i get is a new local storage, not a new database

var people = new Lawnchair('people');

the problem is that in local storage I have just one table, and i need to be able to create more than just one table.

2

There are 2 best solutions below

0
On

You can ref to this page for local database usage.But not all browser support it yet.

http://blog.darkcrimson.com/2010/05/local-databases/

0
On

You might want to use Web SQL Database, but that's implemented only by Chrome, Safari, and Opera. If that is not a problem look here: http://www.html5rocks.com/tutorials/offline/storage/

By the way what do you mean with

in local storage I have just one table

?

You could use the local storage to hold different values, like so:

localStorage['foo'] = "foo";
localStorage['bar'] = "bar";
localStorage['baz'] = "baz";

Values are strings, so you can also save say json or something else if you like.