Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 5 with RxDB (idb adaptor) threws Uncaught TypeError: winningRev is not a function error when creating database

I am using Angualr Cli 1.6.5(Angular 5.2.0) with RxDB 7.3.2 and pouchdb-adapter-idb 6.4.2.

When I tried to create/connect to the database i am getting this errors:

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.

This is the function i am calling from:

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});
}

The database schema:

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

};

and i simply called this function in a component as such:

constructor(private databaseService: DatabaseService) {}

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

I have searched on the internet but couldn't find a similar issue. Does any encounter this error with the similar settings?

Update The link @lossleader provide does work, thank

like image 686
forkadam Avatar asked Dec 06 '25 16:12

forkadam


1 Answers

PouchDB 6.4.2 shipped with broken es modules due to a bug in the version of rollup it was transpiled with. (The transpiler bug removed the as Y from import X as Y syntax without renaming local X variables to prevent shadowing.)

PouchDB 6.4.3 has now been published to npm and was transpiled with rollup 0.55.1 which fixes the bug so updating should resolve the problem.

like image 95
lossleader Avatar answered Dec 08 '25 13:12

lossleader