wheb-mongo: MongoDB plugin for Wheb

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.



Wheb plugin for MongoDB.

For a complete example, see the examples folder at github

You can override the collection names for the Auth and Session documents by using addSetting and setting keys for "session-collection" and "auth-collection"

opts <- generateOptions $ do
   addSetting "session-collection" "my-collection"

Reimplimentation of official example below. Use with language extensions OvererloadedStrings & ExtendedDefaultRules.

 import qualified Data.Text.Lazy as T

 import           Web.Wheb
 import           Web.Wheb.Plugins.Mongo

 data MyApp = MyApp MongoContainer
 data MyRequestState = MyRequestState

 instance MongoApp MyApp where
     getMongoContainer (MyApp mc) = mc

 homePage :: WhebHandler MyApp MyRequestState
 homePage = do
     teams <- runAction $ rest =<< find (select [] "team")
     text $ T.intercalate " | " $ map spack teams

 main :: IO ()
 main = do
   opts <- generateOptions $ do
     addGET "." rootPat $ homePage
     mongo <- initMongo "" "master"
     return (MyApp mongo, MyRequestState)

   runRawHandler opts $ do
     runAction $ do
         delete (select [] "team")
         insertMany "team" [
             ["name" =: "Yankees", "home" =: ["city" =: "New York", "state" =: "NY"], "league" =: "American"],
             ["name" =: "Mets", "home" =: ["city" =: "New York", "state" =: "NY"], "league" =: "National"],
             ["name" =: "Phillies", "home" =: ["city" =: "Philadelphia", "state" =: "PA"], "league" =: "National"],
             ["name" =: "Red Sox", "home" =: ["city" =: "Boston", "state" =: "MA"], "league" =: "American"] ]

   runWhebServer opts


Change logNone available
Dependenciesbase (==4.7.*), bson (==0.3.*), mongoDB (==2.0.*), mtl (>=2.1 && <2.3), text (>=1.0 && <1.2), Wheb (==0.2.*) [details]
AuthorKyle Hanson
Home pagehttps://github.com/hansonkd/Wheb-Framework
UploadedSun Aug 3 17:08:21 UTC 2014 by hansonkd




Maintainers' corner

For package maintainers and hackage trustees