| Safe Haskell | None |
|---|
Snap.Snaplet.MongoDB.Core
Description
In this module you can find the Snaplet's data type, type class and initializer.
- data MongoDB = MongoDB {}
- class HasMongoDB app where
- getMongoDB :: app -> MongoDB
- type MongoDBPool = Pool IOError Pipe
- mongoDBInit :: Int -> Host -> Database -> SnapletInit app MongoDB
Documentation
Snaplet's data type.
Usage:
data App = App
{ _heist :: Snaplet (Heist App)
, _database :: Snaplet MongoDB
}
Constructors
| MongoDB | |
Fields | |
class HasMongoDB app whereSource
Snaplet's type-class.
Usage:
instance HasMongoDB App where
getMongoDB = getL (snapletValue . database)
Note: The (.) is from Category.
Methods
getMongoDB :: app -> MongoDBSource
type MongoDBPool = Pool IOError PipeSource
MongoDB Pool type
Arguments
| :: Int | Maximum pool size. |
| -> Host | Host (e.g. return value of MongoDB's host function). |
| -> Database | Database name. |
| -> SnapletInit app MongoDB |
Initializer function.
Usage:
app :: SnapletInit App App
app = makeSnaplet "app" "Example application." Nothing $ do
h <- nestSnaplet "heist" heist $ heistInit "resources/templates"
d <- nestSnaplet "database" database $ mongoDBInit 10 (host "127.0.0.1") "Snaplet-MongoDB"
return $ App h d