nano
nano copied to clipboard
add reference to server in doc scope
This PR adds the ability to get at the serverScope from a docScope. (which is not currently possible)
If you initialize nano with a db-name in your URL, (a common practice) it effectively becomes impossible to access the server scope:
var db = nano('http://localhost:5984/mydb');
// there is no way to access server scope, for something like server.auth()
In my case, I'm using a single database for my application, but I'm also trying to use _users for handling auth. I'm forced to create 2 different nano refs, which is just a little clumsy.
var server = nano('http://localhost:5984');
var db = server.use('mydb');
server.auth(); // user login
db.get(); // document retrieval
This PR adds support for the following:
var db = nano('http://localhost:5984/mydb');
db.server.auth(); // user login
db.get(); // document retrieval
While I could just say this is a convenience method, I think it's a little bit more than that since a common pattern like specifying a db-name completely excludes this functionality.
Thanks for the contribution.
This has been moved to the ASF, so I'm unsure if I can accept and publish new versions of nano.
Please advise @janl @jo @rnewson
Hi, best thing to do is so submit a PR against https://github.com/apache/couchdb-nano/ instead.
I've ported this PR to the other repo