2016-09-29 88 views
0

This page提到聚合物:使用App-IndexedDB的鏡與聚合物文檔應用-pouchdb文檔

由於PouchDB可以自動與本地IndexedDB的數據庫同步數據,它從來沒有被更容易添加offline-第一個數據訪問您的漸進網絡應用程序。

我對Indexeddb和pouchdb相當陌生,實際上很難將其付諸實踐。我的代碼到目前爲止:

<iron-ajax 
     auto 
     url="../data/some_data.json" 
     handle-as="json" 
     last-response="{{liveData}}"> 
    </iron-ajax> 

    <app-indexeddb-mirror 
     key="thedata" 
     data="{{liveData}}"> 
    </app-indexeddb-mirror> 

    <app-pouchdb-document 
     id="pouchdb" 
     db-name="data" 
     doc-id="thedata" 
     data="{{storedData}}"> 
    </app-pouchdb-document> 

    <template is="dom-repeat" items="{{storedData}}" as="item"> 
     <div>[[item.name]]</div> 
    </template> 

上述不起作用。並且打印pouchdb的所有文檔都是空白的。有人可以提供一個工作示例嗎?或者至少澄清這兩個要素之間的關係?

回答

0

Pouchdb直接使用IndexDB,所以你不需要使用app-indexdb-mirror。