db.createIndex is not a function

Viewed 1722

I am working with Ionic 3, Angular 4, Pouchdb, Pouchdb-find Pouchdb works fine. I have installed both pouchdb and pouchdb-find via npm

steps to reproduce

npm

ionic start testapp
npm install pouchdb
npm install pouchdb-find
ionic serve -l

here is a brief of my component using a blank ionic 3 template

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import PouchDB from 'pouchdb';
declare var require: any;


@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController) {


    PouchDB.plugin(require('pouchdb-find'));

    var db = new PouchDB('pillsalarm3');

    db.createIndex({
      index: {fields: ['type']}
    });
  }           
}

when I run I get this error:

Uncaught (in promise): TypeError: db.createIndex is not a function TypeError: db.createIndex is not a function at new HomePage (http://localhost:8101/build/main.js:57:12) at createClass (http://localhost:8101/build/vendor.js:11251:26) at createDirectiveInstance

1 Answers
Related