我想知道使用离子(角度)框架的混合应用程序是否可以进行以下配置:
如果我们使用带有 pouch db 适配器pouchdb-adapter-cordova-sqlite的cordova-sqlite-plugin,这应该可以工作,但它不适用于加密的适配器。
我面临的问题是打字稿无法转换。我不知道如何设置环境并使用密钥定义 sqlite-cipher 数据库。
这是一些示例打字稿代码:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import PouchDB from 'pouchdb';
import cordovaSqlitePlugin from 'pouchdb-adapter-cordova-sqlite';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController) {
this.setUpPouch();
}
setUpPouch(){
PouchDB.plugin(cordovaSqlitePlugin);
let db = new PouchDB('dummypouch.db', { adapter: 'cordova-sqlite', key:"dummy_key"});
}
}
我想知道是否有办法将密钥传递给 PouchDB 适配器而不破坏转译。
使转译失败的行:
let db = new PouchDB('dummypouch.db', { adapter: 'cordova-sqlite', key:"dummy_key"});
打字稿转译失败并显示以下消息:
[12:35:30] typescript: src/pages/home/home.ts, line: 21
Argument of type '{ adapter: string; key: string; }' is not assignable to parameter of type
'DatabaseConfiguration'. Object literal may only specify known properties, and 'key' does not exist in type
'DatabaseConfiguration'.
L20: PouchDB.plugin(cordovaSqlitePlugin);
L21: let db = new PouchDB('dummypouch.db', { adapter: 'cordova-sqlite', key:"dummy_key"});
Error: Failed to transpile program
at new BuildError (/Users/santi/dummy_project/dummy_push_test/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
at /Users/santi/dummy_project/dummy_push_test/node_modules/@ionic/app-scripts/dist/transpile.js:159:20
at new Promise (<anonymous>)
at transpileWorker (/Users/santi/dummy_project/dummy_push_test/node_modules/@ionic/app-scripts/dist/transpile.js:107:12)
at Object.transpile (/Users/santi/dummy_project/dummy_push_test/node_modules/@ionic/app-scripts/dist/transpile.js:64:12)
at /Users/santi/dummy_project/dummy_push_test/node_modules/@ionic/app-scripts/dist/build.js:109:82
[12:35:30] copy finished in 2.47 s