0

I am trying to adapt syncing data with pouchdb for Ionic 2 RC.0: http://www.joshmorony.com/syncing-data-with-pouchdb-and-cloudant-in-ionic-2/for

I have installed pouchdb:

npm install pouchdb

Import it in data.ts file:

import pouchdb from 'pouchdb';

But I am unable to use it this.db = new pouchdb('abc');

Nothing is displaying on the screen.

1 Answer 1

0

This is what I did with PouchDB and Ionic 2 rc0.

npm install --save pouchdb to install PouchDB

npm install --save @types/pouchdb to install PouchDB typings

Then, in your code you have to import PouchDB:

import PouchDB from 'pouchdb';

To initialize your db:

this.db = new PouchDB( 'myDB', {adapter: 'websql'} );

If you need to synchronize your db with local CouchDB server (very useful to have a look at your PouchDB db content):

this.remote = 'http://localhost:5984/myDB';
let options = {
  live: true,
  retry: true,
  continuous: true
};
this.db.sync( this.remote, options );

If it still doesn't work, then try:

typings install --global --save dt~pouchdb dt~pouchdb-adapter-websql dt~pouchdb-browser dt~pouchdb-core dt~pouchdb-http dt~pouchdb-mapreduce dt~pouchdb-node dt~pouchdb-replication

Good luck to you, as Ionic 2 rc0 is a nightmare to compile (build) for now...

The Ionic team is working hard to solve compilation problems, but it still sucks...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.