changed formatting in tutorial
This commit is contained in:
parent
f23d44195b
commit
d1366e2261
1 changed files with 36 additions and 42 deletions
30
tutorial.md
30
tutorial.md
|
@ -6,12 +6,12 @@ MongoDB Haskell Mini Tutorial
|
|||
__Updated:__ 2/28/2010
|
||||
|
||||
This is a mini tutorial to get you up and going with the basics
|
||||
of the Haskell mongoDB drivers. It is modeled after the python tutorial
|
||||
pymongo available here: http://api.mongodb.org/python/1.4%2B/tutorial.html
|
||||
of the Haskell mongoDB drivers. It is modeled after the
|
||||
[pymongo tutorial](http://api.mongodb.org/python/1.4%2B/tutorial.html).
|
||||
|
||||
You will need the mongoDB bindings installed as well as mongo itself installed.
|
||||
|
||||
>$ = command line prompt
|
||||
$ = command line prompt
|
||||
> = ghci repl prompt
|
||||
|
||||
|
||||
|
@ -20,36 +20,30 @@ Installing Haskell Bindings
|
|||
|
||||
From Source:
|
||||
|
||||
> $ git clone git://github.com/srp/mongoDB.git
|
||||
|
||||
> $ cd mongoDB
|
||||
|
||||
> $ runhaskell Setup.hs configure
|
||||
|
||||
> $ runhaskell Setup.hs build
|
||||
|
||||
> $ runhaskell Setup.hs install
|
||||
$ git clone git://github.com/srp/mongoDB.git
|
||||
$ cd mongoDB
|
||||
$ runhaskell Setup.hs configure
|
||||
$ runhaskell Setup.hs build
|
||||
$ runhaskell Setup.hs install
|
||||
|
||||
From Hackage using cabal:
|
||||
|
||||
> $ cabal install mongoDB
|
||||
|
||||
$ cabal install mongoDB
|
||||
|
||||
Getting Ready
|
||||
-------------
|
||||
|
||||
Start a MongoDB instance for us to play with:
|
||||
|
||||
> $ mongod
|
||||
$ mongod
|
||||
|
||||
Start up a haskell repl:
|
||||
|
||||
> $ ghci
|
||||
$ ghci
|
||||
|
||||
Now We'll need to bring in the MongoDB/BSON bindings:
|
||||
|
||||
> import Database.MongoDB
|
||||
|
||||
> import Database.MongoDB.BSON
|
||||
|
||||
Making A Connection
|
||||
|
@ -103,7 +97,6 @@ Querying for More Than One Document
|
|||
------------------------------------
|
||||
|
||||
> cursor <- find con curcol (toBsonDoc [("author", toBson "Mike")])
|
||||
|
||||
> allDocs cursor
|
||||
|
||||
You can combine these into one line:
|
||||
|
@ -137,4 +130,5 @@ Indexing
|
|||
WIP - coming soon.
|
||||
|
||||
Something like...
|
||||
|
||||
> index <- createIndex con testcol [("author", Ascending)] True
|
||||
|
|
Loading…
Reference in a new issue