【发布时间】:2018-04-07 13:41:40
【问题描述】:
我正在我的 Vue + Laravel 应用程序中添加一个 indexedDB,这是我目前正在使用的代码:
export default {
mixins: [VueGoogleMap.MapElementMixin],
created() {
this.eventBus.$on("refresh-map", () => {
this.fetchHexagons();
});
const getAllBuildings = () => Vue.http.get("/sandbox/buildings");
getAllBuildings().then((result) => {
const async = Dexie.async;
const spawn = Dexie.spawn;
const db = new Dexie("buildings");
db.version(1).stores({
buildings: `++dexie_id, id, name, address, city, nr_units, lat, long, purchased`,
});
db.transaction("rw", db.buildings, function* () {
result.body.forEach(function*(el) {
const a = yield db.buildings.add({
id: el.id,
name: el.name,
address: el.address,
city: el.city,
nr_units: el.nr_units,
lat: el.lat,
long: el.long,
purchased: el.purchased,
});
});
console.log("done");
}).catch(function(err) {
// Catch any error event or exception and log it:
console.error(err.stack || err);
});
如您所见,我正在查询数据库以传输 indexedDB 中的所有建筑物,以便更快地解析它们(我需要在地图中显示它们..)。问题是,当我运行此代码时,出现以下错误:
CanvasOverlay.vue?e208:68 Error: Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
at Transaction.create (dexie.es.js?f8d5:2900)
at eval (dexie.es.js?f8d5:2222)
at eval (dexie.es.js?f8d5:1343)
at callListener (dexie.es.js?f8d5:1026)
at endMicroTickScope (dexie.es.js?f8d5:1113)
at IDBOpenDBRequest.eval (dexie.es.js?f8d5:1180)
我唯一安装的包是 Dexie:
npm install --save dexie
我需要安装更多东西还是可能是 Webpack 问题?
【问题讨论】:
-
能否请您更改问题的标题,以便对其他人更有用?就目前而言,您的标题非常广泛。您的问题专门针对 dexie 的问题以及特定类型的 indexedDB 错误。请考虑提及这些事情。