PouchDB 6.2 incorpore pouchdb-find
import PouchDB from 'pouchdb'
import PouchFind from 'pouchdb-find'
PouchDB.plugin(PouchFind)
this does not work import PouchFind from 'pouchdb-find' It's not a module
import PouchDB from 'pouchdb' only It does not work either
Error fetching users TypeError: _this.db.find is not a function
How should we use pouchdb-find in pouchdb 6.2 ??
Thank you
I am having a similar problem. Using webpack, it complains with the following:
WARNING in ../Scripts/pouchdb-6.2.0.js
Critical dependencies:
7:480-487 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
@ ../Scripts/pouchdb-6.2.0.js 7:480-487
WARNING in ../Scripts/pouchdb.find.js
Critical dependencies:
8:113-120 This seems to be a pre-built javascript file. Though this is possible, it's not recommended. Try to require the original source to get better results.
@ ../Scripts/pouchdb.find.js 8:113-120
When my page loads my built bundle, the code that imports pouchdb and pouchdb-find:
var PouchDB = require('pouchdb');
var _pouchDBFind = require('pouchdb-find');
PouchDB.plugin(_pouchDBFind);
I get the following errors in my console:
main.bundle.js:112089 pouchdb-find plugin error: Cannot find global "PouchDB" object! Did you remember to include pouchdb.js?
main.bundle.js:100758 Uncaught Error: Invalid plugin: got "[object Object]", expected an object or a function
at Function.PouchDB$5.plugin (main.bundle.js:100758)
at Object.(main.bundle.js:95474)
at __webpack_require__ (main.bundle.js:30)
at Object.(main.bundle.js:72014)
at Object.module.exports.surveySchema.retrievalKeyPath (main.bundle.js:75972)
at __webpack_require__ (main.bundle.js:30)
at Object.(main.bundle.js:119)
at Object.module.exports.sitesurvey (main.bundle.js:307)
at __webpack_require__ (main.bundle.js:30)
at main.bundle.js:50
The pouchdb-find code seems to want to register itself as a plugin rather than returning an object to be registered.
@enzoaeneas Don't use the pre-built pouchdb and pouchdb-find bundles.
Rather do something like this:
command-line -> npm install pouchdb-browser pouchdb-find
Then in your file:
var PouchDB = require('pouchdb-browser');
PouchDB.plugin(require('pouchdb-find'));
import * as PouchDB from 'pouchdb';
import * as PouchDBFind from 'pouchdb-find';
PouchDB.plugin(PouchDBFind);
This works!!!
but before
into to node_modules
and rm *
and npm install
Thank you
@garrensmith
that worked. thank you.
Most helpful comment
import * as PouchDB from 'pouchdb';
import * as PouchDBFind from 'pouchdb-find';
PouchDB.plugin(PouchDBFind);
This works!!!
but before
into to node_modules
and rm *
and npm install
Thank you