Created
June 12, 2010 05:39
-
-
Save softa/435449 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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