helun / Ektorp

Java API for CouchDB
Apache License 2.0
299 stars 146 forks source link

dbPath.append() is not actually appending to `path` #260

Closed peetersn closed 7 years ago

peetersn commented 7 years ago

Perhaps I don't fully understand the purpose of the append() method, but it seems that it's not changing the pathvariable (it returns the string with whatever we append to it, escaped) and there's no method to set the path either.

public String append(String s) {
        return path + escape(s);
}

In my case, I want to be able to add a parameter to the HTTP request that I sent when I create a database (Cloudant specific), and that is quite hard to do with the current API. I would like to avoid to resort to have to build a new HTTP request outside of Ektorp just to do that.

YannRobert commented 7 years ago

What parameter would you want to add to the HTTP request ?

Are you using the org.ektorp.CouchDbInstance#createDatabaseIfNotExists(java.lang.String) method? Maybe you can achieve what you want by overriding it ?

Ektorp might not be the best tool available to create Cloudant databases. When I was using Cloudant a few years ago, I was not using Ektorp to create databases. I think I used curl scripts.

If I remember correctly, you use an admin account to create databases, then you use an application account to use them.

peetersn commented 7 years ago

I ended up using the RestTemplate directly.

peetersn commented 7 years ago

@YannRobert You are right indeed. I found another way (by using the RestTemplate directly).