Skip to content

Instantly share code, notes, and snippets.

@softa
Created June 12, 2010 05:39
Show Gist options
  • Save softa/435449 to your computer and use it in GitHub Desktop.
Save softa/435449 to your computer and use it in GitHub Desktop.
module Mongo where
import Database.MongoDB
import Database.MongoDB.BSON
import Network
import Data.ByteString.Lazy.UTF8
fS = fromString
db = fS "yourdb"
usr = "youruser" :: Username
pass = "yourpass" :: Password
students = fS "yourdb.yourcollection"
main :: IO ()
main = do
con <- connectOnPort "subdomain.mongohq.com" (Network.PortNumber 27024) []
l <- login con db usr pass
insert con students (toBsonDoc [("author", toBson "João Milho"),("text", toBson "Hello MongoHQ World!")])
docs <- find con students (toBsonDoc [("author", toBson "João Milho")]) >>= allDocs
putStrLn (show docs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment