简体   繁体   English

如何创建在会话之间持久存在的客户端数据库?

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

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 我正在使用HTML5使用Lawnchair Javascript库创建客户端数据库,但是当您创建新的Lawnchair对象时,我得到的是新的本地存储,而不是新的数据库

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. 问题是在本地存储中我只有一个表,而且我需要能够创建多个表。

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/ http://blog.darkcrimson.com/2010/05/local-databases/

You might want to use Web SQL Database, but that's implemented only by Chrome, Safari, and Opera. 您可能要使用Web SQL数据库,但这仅由Chrome,Safari和Opera实现。 If that is not a problem look here: http://www.html5rocks.com/tutorials/offline/storage/ 如果这不是问题,请看这里: 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. 值是字符串,因此您还可以保存json或其他内容(如果需要)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM