So httppouch has 2 destroy methods, an instanced method on the db and a
static method on the constructor,

You get the instance one when you call db.destroy() and the static one when
you call PouchDB.destroy('dbname')

Your problems are all related to trying to get the the static one to play
nice with your child class even though the static method does inherit any
of your changes.  My suggestion was that your class's destroy method just
create a new instance of the db (which wouldn't great a new db just a new
connection) and then use the instances destroy method (which will have the
proper and version of get host) to destroy the remote instance.

In general I've been trying to get pouch to move away from the static
method of destroying databases because of things like this and try to get
db.destroy () be the preferred way to destroy one.

The other thing to hear in mind is that the scope of the static destroy
method (this value) is not used internally so I'd really prefer it if you
didn't rely on it.
On Mar 20, 2014 9:28 PM, "yaronyg" <notifications@github.com> wrote:

> In lib/adapters/http.js:
>
> > @@ -1006,7 +1012,11 @@ function HttpPouch(opts, callback) {
> >
> >  // Delete the HttpPouch specified by the given name.
> >  HttpPouch.destroy = utils.toPromise(function (name, opts, callback) {
>
> @calvinmetcalf <https://github.com/calvinmetcalf> your questions make it
> absolutely clear that I have failed to explain what I am doing and why.
> Since the burden is rightfully on me to make myself clear let me try to
> explain what I'm doing in a completely different way in the hope that maybe
> it will make sense.
>
> Think of this as an object oriented system. We have an abstract class
> called adapter that is defined as:
>
> public abstract class adapter {
>    public adapter();
>    protected getHost();
>    public destroy();
>    ...
> }
>
> We then have an implementation of adapter:
>
> public class HttpPouch : adapter {
>    public HttpPouch() {
>       ...
>    }
>    protected getHost() {
>       ...
>    }
>    public destroy() {
>       ...
>    }
>    ...
> }
>
> Now anyone can create an adapter, they just inherit from the abstract
> adapter class and off they go, just like HttpPouch did.
>
> But in my case I'm working on something called Thali and it turns out that
> 99.9% of the functionality I need for my HttpKeyPouch adapter is already
> implemented by HttpPouch. Because of this I wrote my adapter as:
>
> public class HttpKeyPouch : HttpPouch {
>    public HttpKeyPouch() {
>       super();
>    }
>   @override
>    protected getHost() {
>       completely ignore getHost from HttpPouch and do something totally different
>    }
>   @override
>   public  destroy() {
>       do stuff;
>       super();
>    }
> }
>
> In the case of getHost none of the functionality in HttpPouch applies
> because the Thali URL type (called httpkey) has a different structure than
> a HTTP URL. So if you applied getHost() as defined in HttpPouch to a
> httpkey URL you would get junk. So I need to completely override getHost()
> and replace it with my own functionality.
>
> To make this really concrete here is a HTTP URL:
> http://foo.com/blah/
> and here is a httpkey URL used by Thali:
> httpkey://
> foo.com/rsapublic:1231231232.123123123123123123123123123213..123123123.235230572...234/blah/
>
> So if you fed the httpkey URL to HttpPouch's getHost (even assuming you
> fixed the issue with the regex) you would get back total junk. httpkey has
> a different structure and syntax than http. Yes, they are similar, but they
> are not the same. Which is why HttpKeyPouch.getHost() function has to be
> completely and totally different from HttpPouch.getHost().
>
> But all the other methods that HttpPouch supports are just fine. Either,
> in the case of destroy, I need to do a tiny bit of work before just calling
> HttpPouch's destroy or for other methods (because I've successfully
> replaced getHost and xhr) I don't need to do anything and the existing
> HttpPouch functionality can run as-is.
>
> The problem then being that Javascript is not an object oriented language
> (well sorta, EcmaScript 5 has some features but let's not go there) and
> this kind of inheritance is not directly supported so I have to fake it.
> Which is what this PR is meant to accomplish.
>
> With this PR I can completely override getHost in all methods in
> HttpPouch. Which is the main thing I need. I can already override destroy
> and the reason why I directly call HttpPouch inside of the HttpKeyPouch
> object (the question you originally asked above) is because after I take
> over getHost and set the options then I want to use HttpPouch's destroy to
> issue the actual DELETE method.
>
> I apologize for the length of this comment but I don't know a shorter way
> to explain what I'm up to. Sorry.
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/daleharvey/pouchdb/pull/1683/files#r10824717>
> .
>