我正在尝试从CB数据库中过滤项目 当我调用此函数时,我收到错误,因为无法读取未定义的属性"queryView">
refresh() {
this.couchbase.getDatabase().queryView("_design/Tickets1", "items", {}).then((result: any) => {
this.items = [];
for(var i = 0; i < result.rows.length; i++) {
this.items.push(result.rows[i].value);
}
}, error => {
console.error("ERROR: " + JSON.stringify(error));
});
}
我对 couchDB 很陌生任何帮助
这来自于在浏览器中运行Ionic。 Couchbase Mobile目前不支持这一点。 您需要在实际设备或模拟器上运行。
以下是运行示例的步骤:
git clone https://github.com/couchbaselabs/todolite-ionic2.git
cd todolite-ionic2/
npm install
npm install -g cordova ionic
— 编辑 package.json 并删除以下内容:
"cordovaPlugins": [
"cordova-plugin-statusbar",
"cordova-plugin-whitelist",
"cordova-plugin-device",
"cordova-plugin-console",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard",
{
"locator": "https://github.com/couchbaselabs/Couchbase-Lite-PhoneGap-Plugin.git",
"id": "com.couchbase.lite.phonegap"
}
],
"cordovaPlatforms": [
"ios",
{
"platform": "ios",
"version": "",
"locator": "ios"
},
{
"platform": "android",
"version": "",
"locator": "android"
}
],
ionic cordova plugin add couchbase-lite-phonegap-plugin
npm install --save-dev @ionic/app-scripts@latest
npm install --save-dev @ionic/cli-plugin-ionic-angular @ionic/cli-
plugin-cordova
npm install --save sw-toolbox
— 在进行 npm 安装的过程中,你会被问到另外两个包,如下所示。 对两者都回答 Y。
Looks like this is an Ionic Angular project, would you like to install @ionic/cli-plugin-ionic-angular and continue? (Y/n)
? The plugin @ionic/cli-plugin-cordova is not installed. Would you like to install it and continue? (Y/n)
cd src/app/
git mv main.dev.ts main.ts
git rm main.prod.ts
cd ../..
ionic cordova run android --device
如果在最后一步后遇到问题,请运行
cordova -d run android --device
以获取有关问题所在的信息。