PouchDB - destroy is not a function


#1

Hey @ all,

I have an issue with PouchDB and I did not found a solution by now.

I have a PouchDB instance created by a provider, but I would also like to destroy the database and reload all data from an API again, because deleted documents are still inside the PouchDB instance.

Anyway I initiate PouchDB like this:

...
import * as PouchDB from 'pouchdb';
...
export class SomeProvicer {
public db: any;

   constructor() {
	 	if (!this.db || this.db === null) {
			this.db = new PouchDB('test');
		}
    }

	truncatePouchDB() {
		console.log("Step 1");
		PouchDB.destroy('test').then(function() { 
			console.log("Step 1");
			this.db = null;
			console.log("Step 2");
			this.db = new PouchDB('test');
			console.log("Step 3");
		});
	}
...
}

The creation aso works fine, also to insert documents - but it won’t destroy the PouchDB, but it’s causing an error (see attached image).

Does anyone know what it is?

Thanks,
Oliver