我尝试在 indexed-db 中创建多个记录,但它不允许我,例如 nike 和 adidas objectStores
var nike = Lawnchair({adapter:'indexed-db', name:'stores', record:'nike'},function(e){
console.log("nike store open");
this.save({id:1}, function(data){
console.log('nike data: ', data);
});
});
var adidas = Lawnchair({adapter:'indexed-db', name:'stores', record:'adidas'},function(e){
console.log("adidas store open");
this.save({id:1}, function(data){
console.log('adidas data: ', data);
});
});
我认为这是如何在 indexed-db 中创建多条记录。它实际上发生在 request.onupgradeneeded 上。请参阅下面的代码。
// Handle datastore upgrades.
request.onupgradeneeded = function(e) {
var db = e.target.result;
var nike = db.createObjectStore('nike');
var adidas = db.createObjectStore('adidas');
};
如果我无法创建 adidas 记录,这实际上是访问它时引发的错误。
[Exception... "The operation failed because the requested database object could not be found. For example, an object store did not exist but was being opened." code: "8" ...]