angular - 如何使用 Angular-Cli/Webpack 导入 PouchDb-Find

标签 angular webpack pouchdb

我想将 Angular 2/Typescript 与 PouchDb 和 PouchDb-Find 一起使用,并使用 Angular-cli(现在基于 webpack)生成的项目。PouchDb 通过一个简单的 import 语句进行连接。

从“pouchdb”导入 * 作为 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) ;
});

新的 PouchDb 可以工作,而 commonDb.getIndexes 则不能。我尝试了 import * as pouchfind from 'pouchdb-find' 的多种变体,但均无济于事。

如何导入 PouchDb-Find 模块?

最佳答案

这对我有用。

安装 npm 软件包。

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

并编写了这段代码

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

关于angular - 如何使用 Angular-Cli/Webpack 导入 PouchDb-Find,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38686371/

相关文章:

html - ionic 4 Angular : Is it possible to have a fixed element in content while using infinite refresher?

angular - 在动态创建的组件angular 2中调用方法

javascript - importvelocity.ui总是返回 'Velocity must be loaded first. Aborting.'

css - 如何使用 webpack 在 React 应用程序中包含 "leaflet.css"?

database - 如何将文档从一个数据库复制到另一个数据库,并在复制完成后删除原始数据库上的文档

angular - 使用 mat paginator 方法 firstPage() 进行功能单元测试

angular - Angular 6 中不纯管道的替代方案?

reactjs - 用于 webpack 的 create-react-app markdown-loader

meteor - IBM Cloudant、PouchDB、Hoodie、Meteor 之间的关系

javascript - Electron Angular2 PouchDB