【问题标题】:require is not defined when using PouchDB filtered replication使用 PouchDB 过滤复制时未定义 require
【发布时间】:2015-06-18 10:55:02
【问题描述】:

我在 PouchDB 和 CouchDB 之间设置了双向复制,我想过滤复制,以便只有相关的文档最终会出现在我的本地邮袋中。

pouchDB('medic').sync('http://localhost:5984/medic', {
  live: true,
  retry: true,
  filter: 'medic/doc_by_place'
});

当我执行同步时,我会从下面的匿名函数中获得 Uncaught ReferenceError: require is not defined

(function () { return function(){return require("lib/app")["filters"]["doc_by_place"].apply(this, arguments);} })()

这是从哪里来的?为什么没有定义require

【问题讨论】:

    标签: couchdb pouchdb


    【解决方案1】:

    此错误来自 syncto 端,而不是 from 端。服务器端过滤器仅对 from 调用有意义。要过滤 to 复制,请执行 adhoc filter function

    我最终将复制分成两个,如下所示。

    pouchDB('medic')
      .replicate.from('http://localhost:5984/medic', {
        live: true,
        retry: true,
        filter: 'medic/doc_by_place'
      });
    
    pouchDB('medic')
      .replicate.to('http://localhost:5984/medic', {
        live: true,
        retry: true
      });
    

    【讨论】:

      猜你喜欢
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      • 2015-04-26
      • 2017-09-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多