我在离线应用程序中使用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()
并重新加载。我告诉你这是为了防止这不是一个好的做法,可能会损害我的数据库状态。
由于
答案 0 :(得分:1)
DB.ApiLogs.clear()
的然后处理程序缺少箭头或函数表达式。