Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to nano or database handler #6

Closed
victor73 opened this issue Aug 16, 2012 · 6 comments
Closed

Access to nano or database handler #6

victor73 opened this issue Aug 16, 2012 · 6 comments

Comments

@victor73
Copy link

Is there any way to get access to nano from within a task to do other work/verification? In the previous version, one could call c.stool.driver() from a task to get access to cradle, but since the arguments are now util and doc, there doesn't seem to be an easy way to get the database handle...

@cliffano
Copy link
Owner

Sorry, I took c.stool.driver() out following the major refactoring few versions ago, thinking that no one uses it.

The above commit added it back, you should be able to get a handle of the driver using util.driver (object, not function) from the tasks.
At the moment util.driver is what nano(dbUrl).use(dbName) returns, and not nano(dbUrl), because nano(dbUrl) is easy enough to create in couchtato.js by requiring nano itself.

Would this cover what you need?

@victor73
Copy link
Author

I think it would and I'm updating the code to use the new util.driver (not util.driver()) mechanism At the moment, util.driver is undefined inside my task though...

@victor73
Copy link
Author

Ah, seems that I'm still on 0.1.1, so probably don't have your commit yet...

@cliffano
Copy link
Owner

I just published v0.1.2, please npm install -g couchtato, then couchtato --version to confirm that you get 0.1.2 .

From the task function, you can use util.driver directly, there's no need for 'new'.
E.g.

function (util, doc) {
    util.driver.doSomething();
}

Inspect util.driver to see what nano#use provides.

Please let me know if it works for you.

@victor73
Copy link
Author

Looks good! Thanks very much!

@cliffano
Copy link
Owner

Cool. Thanks for reporting this in the first place :).

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

No branches or pull requests

2 participants