【问题标题】:Why is PouchDB.find() not a function?为什么 PouchDB.find() 不是函数?
【发布时间】:2021-05-28 11:04:24
【问题描述】:

我无法让pouchdb-find 插件工作。我能得到的最接近的是“find is not a function”异常。

  • 平台:Windows Firefox 和 Android Chrome 75.03770.101
  • webpack: ^4.30.0
  • pouchdb:^7.1.1,
  • pouchdb 查找:^7.1.1

我尝试了here的方法,但没有帮助

我还尝试将 pouchdb-find 与 pouchdb-browser 一起使用。

以下是我目前有问题的代码。如果不在 require 末尾添加 .default ,PouchDB 模块本身将无法工作。请注意,在尝试使用 .find() 之前,我确实已经用数据填充了数据库。

// npm install --save pouchdb
// npm install --save pouchdb-find

const PouchDB = require('pouchdb').default;
PouchDB.plugin(require('pouchdb-find'));

const db = new PouchDB(dbName);    
db.find({
    limit: 100
});

我愿意接受任何允许我使用 pouchdb-find 插件的解决方案。

【问题讨论】:

    标签: javascript pouchdb


    【解决方案1】:

    解决方案是模仿我需要 PouchDB 的方式。 (此外,传递给 find() 的对象会产生错误,因为它应该有一个选择器,但这与问题的主题并不真正相关)

    PouchDB.plugin(require('pouchdb-find').default);
    

    【讨论】:

    • 拯救了我的一天 :)
    猜你喜欢
    • 1970-01-01
    • 2021-09-09
    • 2019-10-12
    • 2019-05-25
    • 2021-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多