flatiron / cradle

a high-level CouchDB client for Node.js
MIT License
1.38k stars 182 forks source link

How can we close a database connection after we create it? #310

Open houshengbo opened 8 years ago

houshengbo commented 8 years ago

I have maintain multiple connection to couchdb in one of my projects.

However, after I create the connections with var db = new(cradle.Connection)().database('starwars');

how can I close the database connection???

mike-lang commented 8 years ago

To the best of my knowledge the Connection object doesn't represent a any sort of persistent connection, it's mostly a bundle of configuration information used to make HTTP requests to service specific commands, so you generally wouldn't "close" it. If you need to forcibly close the sockets that are currently open and managed by the HttpAgent servicing the cradle "Connection" you should be able to call the close method on the object, but it appears this doesn't apply to longpoll monitoring of the _changes feed. Those sockets appear to be handled by a different HttpAgent than the other requests made by cradle.

Hope that helps.