带有RxDB的Angular 5(idb适配器)抛出Uncaught TypeError:在创建数据库

时间:2018-02-01 04:02:43

标签: angular-cli indexeddb angular5 pouchdb pouchdb-adapter-localstorage

我正在使用Angualr Cli 1.6.5(Angular 5.2.0)和RxDB 7.3.2以及pouchdb-adapter-idb 6.4.2。

当我尝试创建/连接到数据库时,我收到了这个错误:

zone.js:192 Uncaught TypeError: winningRev is not a function
    at insertDoc (index.es.js:370)
    at nextDoc (index.es.js:449)
    at eval (index.es.js:452)
    at Map.forEach (<anonymous>)
    at processDocs (index.es.js:426)
    at idbProcessDocs (index.es.js:330)
    at checkDone (index.es.js:354)
    at IDBRequest.readMetadata [as __zone_symbol__ON_PROPERTYsuccess] (index.es.js:364)
    at IDBRequest.wrapFn (zone.js:1166)
    at ZoneDelegate.invokeTask (zone.js:421)
index-browser.es.js:486 Database has a global failure DOMException: Uncaught exception in event handler.

这是我打电话的功能:

async getRxDB() {
    this.rx_db = await RxDB.create({
        name: 'testdb',
        adapter: 'idb',
        multiInstance: false
    });
    console.log(this.rx_db);

    await this.rx_db.collection({name: 'fork', schema: TestDBSchema});
}

数据库架构:

const TestDBSchema = {
    'title': 'test schema',
    'version': 0,
    'description': 'describes a simple task',
    'type': 'object',
    'properties': {
      'name': {
          'type': 'string',
          'primary': true
      }
    }

};

我只是在一个组件中调用了这个函数:

constructor(private databaseService: DatabaseService) {}

ngOnInit() {
    this.databaseService.getRxDB();
}

我在互联网上搜索过但无法找到类似的问题。 是否有任何类似设置遇到此错误?

更新 @ lossleader提供的链接确实有效,谢谢

1 个答案:

答案 0 :(得分:1)

broken es modules附带的PouchDB 6.4.2由于汇总版本中的错误而被编译。 (转换器错误从as Y语法中删除import X as Y,而不重命名本地X变量以防止出现阴影。)

PouchDB 6.4.3现已发布到npm,并使用汇总0.55.1({3}}进行了转换,因此更新应该可以解决问题。