【发布时间】:2019-07-10 18:06:52
【问题描述】:
我一直在尝试动态更新数据库索引,但一直失败,卡了几天。 我正在使用 angular7 & type 脚本和最新的 dexie 版本。当我尝试使用相同的代码时,它给了我错误:
我应该做些什么来让它工作吗?谢谢!
ERROR Error: Uncaught (in promise): UpgradeError: Dexie specification of currently installed DB version is missing
UpgradeError: Dexie specification of currently installed DB version is missing
我只是在这里复制粘贴示例代码:
changeSchema(db, schemaChanges) {
db.close();
const newDb = new Dexie(db.name);
newDb.version(db.verno + 1).stores(schemaChanges);
return newDb.open();
}
// Open database dynamically:
async playAround() {
let db = new Dexie('FriendsDatabase');
if (!(await Dexie.exists(db.name))) {
db.version(1).stores({});
}
await db.open();
// Add a table with some indexes:
db = await this.changeSchema(db, { friends: 'id, name' });
// Add another index in the friends table
db = await this.changeSchema(db, { friends: 'id, name, age' });
// Remove the age index again:
db = await this.changeSchema(db, { friends: 'id, name' });
// Remove the friends table
db = await this.changeSchema(db, { friends: null });
}
【问题讨论】:
标签: dexie