本文介绍了JavaScript Lawnchair库..存储为相同的“表"吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Lawnchair JavaScript库.参考这里 http://westcoastlogic.com/lawnchair/

I am using Lawnchair JavaScript library. Reference herehttp://westcoastlogic.com/lawnchair/

在下面的代码中,因为我传递了不同的ID,所以TABLE1和TABLE2 ..我希望dao1和dao2完全存储为2个不同的对象/存储.但是事实是他们指的是同一件事..dao1或dao2中的任何保存"动作都将存储在同一"Lawnchair"中.

In below code, because i passed different id, TABLE1 and TABLE2.. I expect dao1 and dao2 are completely be stored as 2 different objects / storage. But the fact is they're referring to the same thing.. and any "save" action from dao1 or dao2, will be stored at the same "Lawnchair".

即(dao1.all和dao2.all将返回相同的数组).

i.e. (dao1.all and dao2.all will return same array).

感谢您的大/小想法/建议..谢谢!

Appreciate for your big/small idea / suggestion.. Thanks!!

        <script src="javascripts/lib/Lawnchair.js" type="text/javascript"></script>
        <script src="javascripts/lib/adaptors/WebkitSQLiteAdaptor.js" type="text/javascript"></script>
        <script src="javascripts/lib/adaptors/DOMStorageAdaptor.js" type="text/javascript"></script>
        <script src="javascripts/lib/adaptors/LawnchairAdaptorHelpers.js" type="text/javascript"></script>

var dao1 = new Lawnchair('TABLE1');
dao1.nuke(); // Clear persistent storage.
dao1.save({111: '222'});

var dao2 = new Lawnchair('TABLE2');
dao2.nuke(); // Clear persistent storage.
dao2.save({333: '444'});

dao1.all(function(a) {
    console.log("dao1")
    console.log(a)
});
dao2.all(function(a) {
    console.log("dao2")
    console.log(a)
});

将在Java控制台中生成类似下面的内容

will produce something like below in Java Console

dao1
m-account.js:112[
Object
333: "444"
key: "ACF3A299-E986-4993-915F-A62FF009E846"
__proto__: Object
]
m-account.js:116
dao2
m-account.js:117[
Object
333: "444"
key: "ACF3A299-E986-4993-915F-A62FF009E846"

原始:对象

推荐答案

草椅可以正常工作:

我认为您可能正在检查错误的内容(即数组长度而不是内容),或者将一个对象放入两个Lawnchair数据库中,或者您可能没有包括所有的Lawnchair JavaScript文件(我的jsfiddle中有多个文件)我不得不从Lawnchair的例子之一中删除该列表.

I think you might be checking the wrong things (i.e. array length rather than contents), or putting one object in two Lawnchair databases, or perhaps you're not including all of the Lawnchair JavaScript files (there are several in my jsfiddle and I had to pull that list out of one of the Lawnchair examples).

这篇关于JavaScript Lawnchair库..存储为相同的“表"吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 06:36