Skip to content

Instantly share code, notes, and snippets.

@hwa
Created August 3, 2014 01:47
Show Gist options
  • Save hwa/e590dac11b789a7aa3f2 to your computer and use it in GitHub Desktop.
Save hwa/e590dac11b789a7aa3f2 to your computer and use it in GitHub Desktop.
{-# 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