我使用鉻25的IDBWrapper.IndexedDB的指標沒有顯示在瀏覽器(使用IDBWrapper)
最新版本我創建存儲:
var countryStore = new IDBStore({
dbVersion: version,
storeName: countryTable,
keyPath: 'id',
autoIncrement: true,
onStoreReady: function() {
console.log('Country store ready, go ahead!');
americanGivingDB.countryStore.count(function (result) {
console.log("The amount found in the countryStore was " + result);
if(result == 0){
initializeCountryStore(countryStore, countryDeferred);
} else {
countryDeferred.resolve();
}
});
},
indexes: [ {name : "areas", keypath: "area", unique: false, multiEntry:true}, {name: "years", keypath: "year", unique: false, multiEntry: true}]
});
我再補充一個巨大的批給它:
for(var i = 0; i < lines.length; i++) {
var fields = lines[i].split(", "); // Comma-separated values
valueToAdd = {
id: id,
area: fields[0],
program: fields[1],
year: fields[2],
amount: fields[3]
}
id++;
operations.push({type: "put", value: valueToAdd});
}
countryCSVxhr.onload = function(e) {
console.log("onload found number of operations to add are " + operations.length);
status("country dataset downloaded, adding to local storage.");
db.batch(operations, function (result) {
status("finished loading the country table");
console.log("finished loading the country table");
americanGivingDB.countryStore.count(function (result) {
status("country dataset added to local storage");
console.log("The amount found in the countryStore was " + result);
countryDeferred.resolve();
});
}, function (error) {
console.log("error", error);
});
}
,然後在索引查詢:
americanGivingDB.countryStore.query(function(results){
//console.log("finished querying the store " + results);
var returnString = "";
for(var i = 0; i < results.length; i++){
returnString = returnString + results[i].area + " \n";
}
console.log("the area names are: \n" + returnString);
},
{
index: "areas",
keyRange: americanGivingDB.countryStore.makeKeyRange({
upper: "Z"
}),
filterDuplicates: true,
onError: americanGivingDB.onErrorHandler
}
);
其中返回一組空的結果。當我查看chrome中的資源時,索引是空白的,我不確定它們是否應該是。
任何想法可能是錯的?