Angular 和 PouchDBFind 插件
Angular and PouchDBFind plugin
我有一个 angular 应用程序,我想在其中使用 PouchDB 和 PouchDBFind 插件。
我已经让 PouchDB 开始工作了。但是我不知道如何使用 PouchDB 插件。
示例数据库设置:
constructor() {
this.db = new PouchDB('exampleDb');
this.db.createIndex({
index: {fields: ['number', 'name']}
}).catch(error => {
console.log(error);
});
}
我总是遇到这个错误:
ERROR Error: Uncaught (in promise): TypeError: this.db.createIndex is not a function
TypeError: this.db.createIndex is not a function
我的导入语句是这样的:
import * as PouchDB from 'pouchdb';
import * as PouchFind from 'pouchdb-find';
PouchDB.plugin(PouchFind);
这里没有任何错误。
我已经阅读了另一种导入替代方法,但这不有效:
import PouchDB from 'pouchdb';
import PouchFind from 'pouchdb-find';
我收到这个错误:
"pouchdb-find" has no default export
我已经安装了打字。
所以这是我的 package.json 依赖项:
"dependencies": {
"@types/pouchdb": "6.1.1",
"@types/pouchdb-find": "^0.10.1",
"pouchdb": "^6.2.0",
"pouchdb-find": "^6.3.4"
},
那么如何让 PouchDBFind 插件工作呢?
如果需要更多信息,请通知我。
提前致谢!
编辑:
将版本锁定为...
"pouchdb": "6.3.4",
"pouchdb-find": "6.3.4",
... webpack 编译后出现如下警告:
WARNING in ./src/app/services/example-db/example-db.service.ts
17:8-22 "export 'plugin' (imported as 'PouchDB') was not found in 'pouchdb'
并且在浏览器控制台中:
ERROR Error: Uncaught (in promise): TypeError: __WEBPACK_IMPORTED_MODULE_2_pouchdb__.plugin is not a function
TypeError: __WEBPACK_IMPORTED_MODULE_2_pouchdb__.plugin is not a function
当我评论 PouchDB.plugin(PouchFind)
行时,警告消失了,但控制台中的错误仍然存在。它只是说它没有构造函数。
编辑:这是一个angular-cli项目。
你能把你的版本锁定到...
"pouchdb": "6.3.4",
"pouchdb-find": "6.3.4"
...然后再试一次?
import PouchFind from 'pouchdb-find';
import PouchDB from 'pouchdb-browser';
PouchDB.plugin(PouchFind);
我有一个 angular 应用程序,我想在其中使用 PouchDB 和 PouchDBFind 插件。
我已经让 PouchDB 开始工作了。但是我不知道如何使用 PouchDB 插件。
示例数据库设置:
constructor() {
this.db = new PouchDB('exampleDb');
this.db.createIndex({
index: {fields: ['number', 'name']}
}).catch(error => {
console.log(error);
});
}
我总是遇到这个错误:
ERROR Error: Uncaught (in promise): TypeError: this.db.createIndex is not a function
TypeError: this.db.createIndex is not a function
我的导入语句是这样的:
import * as PouchDB from 'pouchdb';
import * as PouchFind from 'pouchdb-find';
PouchDB.plugin(PouchFind);
这里没有任何错误。
我已经阅读了另一种导入替代方法,但这不有效:
import PouchDB from 'pouchdb';
import PouchFind from 'pouchdb-find';
我收到这个错误:
"pouchdb-find" has no default export
我已经安装了打字。 所以这是我的 package.json 依赖项:
"dependencies": {
"@types/pouchdb": "6.1.1",
"@types/pouchdb-find": "^0.10.1",
"pouchdb": "^6.2.0",
"pouchdb-find": "^6.3.4"
},
那么如何让 PouchDBFind 插件工作呢? 如果需要更多信息,请通知我。
提前致谢!
编辑: 将版本锁定为...
"pouchdb": "6.3.4",
"pouchdb-find": "6.3.4",
... webpack 编译后出现如下警告:
WARNING in ./src/app/services/example-db/example-db.service.ts
17:8-22 "export 'plugin' (imported as 'PouchDB') was not found in 'pouchdb'
并且在浏览器控制台中:
ERROR Error: Uncaught (in promise): TypeError: __WEBPACK_IMPORTED_MODULE_2_pouchdb__.plugin is not a function
TypeError: __WEBPACK_IMPORTED_MODULE_2_pouchdb__.plugin is not a function
当我评论 PouchDB.plugin(PouchFind)
行时,警告消失了,但控制台中的错误仍然存在。它只是说它没有构造函数。
编辑:这是一个angular-cli项目。
你能把你的版本锁定到...
"pouchdb": "6.3.4",
"pouchdb-find": "6.3.4"
...然后再试一次?
import PouchFind from 'pouchdb-find';
import PouchDB from 'pouchdb-browser';
PouchDB.plugin(PouchFind);