我有两个类型dojo.data.ItemFileReadStore
的数据存储。其中一个数据存储有旧数据,另一个有新数据。如何比较这两个数据存储?
我在两个商店调用了fetch方法并进行了比较,但对我没有用。
答案 0 :(得分:1)
如果同一个项目可以在两个商店中,那么你可以从一个商店获取所有商品,在完成,foreach项目,otherStore.isItem(someItem),它将返回一个布尔值:) 你试过了吗?
答案 1 :(得分:0)
The format used by ItemFileReadStore is not a requirement of the dojo.data API. The
format it uses is designed to work well for the specific situations
ItemFileReadStore is used for, which are moderately sized data sets that can be easily
represented in a JavaScript Object tree.
{
"label": "some attribute", // Optional attribute used to indicate which attribute on
an item should act as a human-readable label for display purposes.
"identifier": "some attribute", // Optional attribute used to indicate which
attribute on an item acts as a unique identifier for that item. If it is not defined,
then the ItemFileReadStore will simply number the items and use that number as a
unique index to the item.
"items:" [ // The array of JavaScript objects that act as the root items of the data
store
{ /* Some set of name/value attributes */ },
{ /* ... */ },
...
]
}
答案 2 :(得分:0)
解决方案1:我们使用了这种方法:
dojo.require("dojo.json");
_equal: function(objA, objB) {
return dojo.json.stringify(objA) === dojo.json.stringify(objB);
}
对象内的数据也应该具有相同的顺序,否则比较将失败。
解决方案2:但是在dojo 1.8中他们引入了dojox/mvc/equals
功能。
它比较了两个给定的对象。
另请考虑使用dojo/store
而不是弃用dojo/data