Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pouchdb.find is not a function

I have an react app created using create-react-app. So using webpack which is bundled with create-react-app. I have to use find() of Pouchdb, which I am unable to do. Other Pouch functionality is working fine but find plugin is not getting attached to Pouch.

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

Versions in package.json :

"pouchdb": "^6.4.1",
"pouchdb-browser": "^6.4.1",
"pouchdb-find": "^6.4.1"

Do anyone have Idea how to fix this. Thanks in advance.

like image 234
Yash Kochar Avatar asked Dec 19 '22 01:12

Yash Kochar


1 Answers

I found the way to solve this problem. Hope it will help others

import PouchDB from 'pouchdb';
import PouchdbFind from 'pouchdb-find';

export class PouchService {
    constructor() {
        PouchDB.plugin(PouchdbFind);
    }
}

After this find() gets included in PouchDB objects.

like image 55
Yash Kochar Avatar answered Dec 31 '22 02:12

Yash Kochar