Introduction to jestermongopool
ver 1.0.1
![nimble](https://raw.githubusercontent.com/yglukhov/nimble-tag/master/nimble.png)
This is a plugin for the nim web framework Jester. It supports the MongoPool library's use with Jester.
GETTING A MONGODB CONNECTION
Include the plugin nextMongoConnection("<failureUrl>")
at the top of your main routes
or primary router
. This will enable the plugin for the whole web site.
The variable connected will be the resulting "next" connection.
If the driver is unable to pull a good connection from the pool of connections,
then web request will be redirected to the failureUrl
provided (and the
page route will not run.)
For example:
import jester
import jestermongopool
import mongopool
import bson
connectMongoPool("mongodb://someone:secret@mongo.domain.com:27017/abc")
routes:
plugin db <- nextMongoConnection("/dberror")
get "/":
var doc = db.find("webday").returnOne()
resp "doc = " & $doc
get "/dberror":
resp "database error.<br /><pre>" & getMongoPoolStatus() & "</pre>"