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