2016-07-28 77 views
0

我使用Dexie在我的離線應用程序,當我嘗試在我的IndexedDB的數據庫中插入新的數據我得到這個錯誤:TypeError: Cannot set property 'onerror' of undefined(…)Dexie - 類型錯誤:未定義(...)無法設置屬性「的onerror」

這是一個似乎是引發錯誤的代碼:

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" 
}); 

自從我加入表作爲我去,我不想科瑞Ë許多數據庫的版本我做了以下清理DB:

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()並重新加載。我只是告訴你,以防萬一,這不是好的做法,可能會危及我的數據庫狀態。

由於

回答

1

然後DB.ApiLogs.clear()處理程序已丟失的箭頭或函數表達式。

相關問題