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.

有帮助吗?

解决方案

PouchDB has a built in method for synchronizing with CouchDB using one- or two-way replication.

I understand that you want to sync with a datasource, which doesn't have a CouchDB compatible API. Then you'll have to write code to perform the synchronization with your specific JSON API.

其他提示

There's a library now which makes it possible to import a JSON string (dump) as database into PouchDB.

It's called PouchDB-Load and is written by PouchDB author Nolan Lawson.

So in your case the code can be as simple as:

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top