【问题标题】:Couchbase Lite views doesnt work after any document updateCouchbase Lite 视图在任何文档更新后都不起作用
【发布时间】:2019-01-16 07:06:08
【问题描述】:
  1. 我们有 couchbase lite 应用程序。我们使用视图在应用程序上显示数据。有一个设计文档,其中包含四个视图。
  2. 设计文档和视图是在数据库准备好后创建的。视图只创建一次。
  3. 当我们更改任何文档或创建一个将进入视图的新文档时,视图会在下一次查询时停止返回文档。它给出了错误

    {"error":"bad_request","status":400,"reason":"路由器无法将请求路由到 do_GET_DesignDocumentcom.couchbase.lite.CouchbaseLiteException: 无法索引视图 cceDesignDoc/draftTransactionView: 没有地图块已注册,状态:400 (HTTP 400 bad_request)"}

  4. 当我们使用 Couchbase Lite 1.4.0 时,视图工作。当我们升级到 1.4.4 时,它不起作用

我们通过类似于以下的 REST API 使用视图:

http://a638931f-0e15-7389-1ae0-q1f7491ac748:72e61883-ca1d-8391-ad1e-474299b8c9a3@localhost:5984/local2368288277/_design/abcDesignDoc/_view/peterAbcTransactionView?

请看下面的相关代码:

// This method is called when app starts up. It is called only once.    
public createView(){
    this.platform.ready().then(() => {
        (new Couchbase()).openDatabase(AppUrl.LOCAL_DB_NAME).then(database => {
            this.database = database;
            let views = {
                myAbcTransactionView: {
                    map: function (doc) {
                        if (doc.type == "myAbcTransaction") {
                            emit(doc._id, doc)
                        }
                    }.toString()
                },
                johnAbcTransactionView: {
                    map: function (doc) {
                        if (doc.type == "johnAbcTransaction") {
                            emit(doc._id, doc)
                        }
                    }.toString()
                },
                peterAbcTransactionView: {
                    map: function (doc) {
                        if (doc.type == "peterAbcTransaction") {
                            emit(doc._id, doc)
                        }
                    }.toString()
                },
                jennaAbcTransactionView: {
                    map: function (doc) {
                        if (doc.type == "jennaAbcTransaction") {
                            emit(doc._id, doc)
                        }
                    }.toString()
                }
            };

            this.database.createDesignDocument("_design/abcDesignDoc", views);

            this.database.listen(change => {
                this.listener.emit(change.detail);
            });
        }
    }

//This method is called to show records in the view on the screen   
public showRecords() {
    this.couchbase.getDatabase().queryView("_design/abcDesignDoc", "peterAbcTransactionView", {}).then((result: any) => {
      this.transactions = [];

      for (var i = 0; i < result.rows.length; i++) {
        this.zone.run(() => {

          this.transactions.push(result.rows[i].value);
          this.transactions.sort(function (b, a
          ) {
            return a.theDate - b.theDate;
          });
        });
      }
    }, error => {
    });
  }

版本信息: 离子:

离子(离子 CLI):4.7.1(AppData\Roaming\npm\node_modules\ionic) 离子框架:离子角 3.3.0 @ionic/app-scripts:1.3.7

科尔多瓦:

cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1) Cordova 平台:安卓 7.1.4 Cordova 插件:没有列入白名单的插件(总共 14 个插件)

系统:

NodeJS : v6.14.4 (C:\Program Files\nodejs\node.exe) npm:3.10.10 操作系统:Windows 10

Couchbase Lite:1.4.4

Couchbase-Lite-PhoneGap-Plugin:(https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin)

【问题讨论】:

    标签: cordova ionic-framework couchbase-lite couchbase-view cordova-android


    【解决方案1】:

    【讨论】:

    • 感谢阿拉德的帮助。我已经尝试过了,它可以正常工作,直到 4 或 5 次插入或更新文档。之后我得到了同样的错误{"error":"bad_request","status":400,"reason":"Router unable to route request to do_GET_DesignDocumentcom.couchbase.lite.CouchbaseLiteException: Cannot index view cceDesignDoc/draftTransactionView: no map block registered, Status: 400 (HTTP 400 bad_request)"}
    【解决方案2】:

    我们发现couchbase-lite 1.4.4 存在上述错误的问题。当我们安装 couchbase-lite 1.4.0 之后,一切都会正常运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多