Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import PouchDb-Find with Angular-Cli/Webpack

I'm want to use Angular 2/Typescript with PouchDb and PouchDb-Find with a project generated with Angular-cli (which is now webpack based.) PouchDb gets wired in with a simple import statement.

import * as PouchDB from 'pouchdb'

var commonDb = new PouchDB(this.commonDbUrl) ;
console.log("commonDb",commonDb) ;

// .getIndexes() is from pouchDb.find. I don't know what the import for it is
commonDb.getIndexes().then(function (result) {
    console.log("GetIndexes.Success",result) ;
}).catch(function (err) {
    console.log("GetIndexes.Failed",err) ;
});

The new PouchDb works, the commonDb.getIndexes does not. I've tried many variations on import * as pouchfind from 'pouchdb-find' to no avail.

How do I import the PouchDb-Find module?

like image 372
jeff Avatar asked Dec 18 '22 14:12

jeff


1 Answers

This works for me.

Install npm packages.

npm install --save pouchdb-browser
npm install --save pouchdb-find

and wrote this code

import PouchDB from 'pouchdb-browser';
import PouchDBFind from 'pouchdb-find';
PouchDB.plugin(PouchDBFind);
like image 153
Katsumi Honda Avatar answered Jan 02 '23 15:01

Katsumi Honda