我在我的离线应用程序中使用 Dexie,当我尝试在我的 Indexeddb 数据库中插入新数据时,我收到此错误:TypeError: Cannot set property 'onerror' of undefined(…)
这是似乎引发错误的代码:
InsertApiLogs: function (Data) {
return DB.transaction('rw', DB.ApiLogs, () => {
DB.ApiLogs.clear().then(
DB.ApiLogs.bulkPut(Data)
);
}).catch( function (E) {
console.log(E);
return false;
});
},
这是我创建数据库的地方:
var DB = new Dexie('local', {autoOpen: true});
DB.version(1).stores({
Event: "EventId, Name, StartDate, EndDate, Description, OriginalUserId, DateCreated, IsArchived, IsRecurring, CreatedInGCal",
Pipeline: "PipelineId, Name, Image, DateCreated, DateArchived, Statuses",
ApiLogs: "APILogId, UserCode, FunctionName, Success, Error, Parameters, ReturnVal, Date",
MySelf: "Type, Data"
});
由于我正在添加表并且我不想创建多个版本的数据库,因此我执行了以下操作来清理数据库:
var DB = new Dexie('local', {autoOpen: true});
DB.delete();
DB.version(1).stores({
Event: "EventId, Name, StartDate, EndDate, Description, OriginalUserId, DateCreated, IsArchived, IsRecurring, CreatedInGCal",
Pipeline: "PipelineId, Name, Image, DateCreated, DateArchived, Statuses",
ApiLogs: "APILogId, UserCode, FunctionName, Success, Error, Parameters, ReturnVal, Date",
MySelf: "Type, Data"
});
然后我删除DB.delete()
并重新加载。我告诉你这是为了以防这不是好的做法,并且可能会损害我的数据库状态。
谢谢