Closed hullionhero closed 13 years ago
In Mongolian DeadBeef there are only callbacks for operations that actually get data from the server, so your code above should be written as:
server.db.comment = db.collection('comment')
Mongolian has its own connection management. It will connect as needed and automatically close the connection after a period of inactivity.
You can override this behavior by passing a {keepAlive:MS} option:
var mongo = new Mongolian({ keepAlive:15000 })
A keepAlive of zero or false will keep the connection open until you call close explicitly:
var mongo = new Mongolian({ keepAlive:0 })
Is having Mongolian manage the connection useful? Should I set keepAlive to 0? If an app is reasonably active you're going to need data from the db all the time, what's the reason for closing the connection?
Thanks.
To put it another way, I think in my usecase I would rather have the connection for being always on. Would there be any downsides?
I agree with you. For the tests it made sense to have the connection close when it's no longer needed, but the default should probably keep the connection alive.
OK thanks, was just making sure I wasn't doing something stupid.
When using mongodb native or mongoose the connection's always open when the server is started.
so I can do:
and then I have server.db.comment always available to add to.
But in Mongolian the connection seems to close immediately? Is this intended behavior? Am I misunderstanding the message?
Thanks.