Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

add reference to server in doc scope #346

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dominicbarnes
Copy link

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.

@dscape
Copy link
Contributor

dscape commented Jan 4, 2017

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

@rnewson
Copy link
Member

rnewson commented Jan 5, 2017

Hi, best thing to do is so submit a PR against https://github.com/apache/couchdb-nano/ instead.

@dominicbarnes
Copy link
Author

I've ported this PR to the other repo

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants