2014-04-04 53 views
0

我想讓PouchDB工作兩天 - 現在一些簡單的東西有些不工作。PouchDB不工作在鉻(種)

這是很難孤立的原因,但我終於設法隔離一個問題 - 問題 與IndexDB銷燬數據庫和再次創建或承諾實現PouchDB我沒有線索。

反正 - 這下面的代碼在Firefox,直到結束,但Chorme,僅得到「創建數據庫...」並沒有任何警告停止(在調試器永遠不會獲取「發佈記錄」)

<!DOCTYPE html> 
<html> 

<head> 
    <meta charset="utf-8"/> 
</head> 

<body> 

<script src="lib/pouchdb/dist/pouchdb-nightly.js"></script> 

<script> 
    new PouchDB('test') 
     .then(function (db) { 
      console.log("Destroying database.. "); 
      return db.destroy() 
     }) 
     .then(function() { 
      console.log("Creating database.. "); 
      return new PouchDB('test'); 
     }) 
     .then(function (db) { 
      console.log("Posting record.. "); 
      return db.post({name: 'name'}); 
     }) 
     .then(function(info){ 
      console.log("Checking id of inserted record: " + info.id); 
     }) 
     .catch(function (error) { 
      console.log(error.message); 
     }); 

</script> 

</body> 
</html> 

任何解決方法?

我需要「銷燬數據庫 - >然後創建新的 - >然後做一些東西」操作流程,每次在每個瀏覽器中工作 - 我試着承諾,回調 - 或者得到像代碼示例或IndxedDB錯誤的結果11 ...

+0

這裏沒問題,在Chrome中創建和刪除數據庫。 – JvdBerg

回答

0

有沒有在你的諾言鏈回事時髦的東西,但這裏有一個解決辦法,不只是罰款:

new PouchDB('test') 
     .then(function (db) { 
      console.log("Destroying database.. "); 
      return db.destroy(); 
     }) 
     .then(function() { 
      console.log("Creating database.. "); 
      return new PouchDB('test').then(function (db) { 
       console.log("Posting record.. "); 
       return db.post({name: 'name'}); 
      }) 
      .then(function(info){ 
       console.log("Checking id of inserted record: " + info.id); 
      }); 
     }) 
     .catch(function (error) { 
      console.log(error.message); 
     }); 

輸出:

Destroying database.. Creating database.. Posting record.. Checking id of inserted record: 0613FFBA-518F-4F20-A1DD-D18E59A4340B

儘管如此,我已經在PouchDB上提交了an issue