【发布时间】:2019-01-16 07:06:08
【问题描述】:
- 我们有 couchbase lite 应用程序。我们使用视图在应用程序上显示数据。有一个设计文档,其中包含四个视图。
- 设计文档和视图是在数据库准备好后创建的。视图只创建一次。
-
当我们更改任何文档或创建一个将进入视图的新文档时,视图会在下一次查询时停止返回文档。它给出了错误
{"error":"bad_request","status":400,"reason":"路由器无法将请求路由到 do_GET_DesignDocumentcom.couchbase.lite.CouchbaseLiteException: 无法索引视图 cceDesignDoc/draftTransactionView: 没有地图块已注册,状态:400 (HTTP 400 bad_request)"}
当我们使用 Couchbase Lite 1.4.0 时,视图工作。当我们升级到 1.4.4 时,它不起作用。
我们通过类似于以下的 REST API 使用视图:
请看下面的相关代码:
// 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