4

I want to create a html page which synchronize JSON data with pouch Db. The JSON data is a response from a web service.I have created a sample html file which can create a pouch Db database.I have created rest web service which gives certain data as response. can any one help me to synchronize these two.

4

2 回答 2

3

PouchDB 具有使用单向或双向复制与CouchDB同步的内置方法。

我了解到您希望与没有与 CouchDB 兼容的 API 的数据源同步。然后,您必须编写代码来执行与特定 JSON API 的同步。

于 2014-01-21T15:13:40.667 回答
2

现在有一个库可以将 JSON 字符串(转储)作为数据库导入 PouchDB。

它被称为PouchDB-Load,由 PouchDB 作者 Nolan Lawson 编写。

因此,在您的情况下,代码可以很简单:

var db = new PouchDB('my-awesome-db'); db.load('http://example.com/my-dump-file.json').then(function () { // done loading! }).catch(function (err) { // HTTP error or something like that });

于 2017-02-09T16:28:53.500 回答