Created
August 3, 2014 01:47
-
-
Save hwa/e590dac11b789a7aa3f2 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
{-# LANGUAGE OverloadedStrings, ExtendedDefaultRules #-} | |
module Main where | |
import Database.MongoDB | |
import Control.Monad (forM_) | |
main :: IO () | |
main = do | |
pipe <- connect (host "127.0.0.1") | |
e <- access pipe master "baseball" run | |
close pipe | |
print e | |
run = do | |
clearTeams | |
forM_ [1..1000] (\_ -> insertTeams) | |
clearTeams = delete (select [] "team") | |
insertTeams = 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"] ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment