Skip to content

Commit

Permalink
Couchdb done, started mongo, dropped the example.
Browse files Browse the repository at this point in the history
  • Loading branch information
spraints committed Mar 29, 2010
1 parent a4d6981 commit 4c78c01
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 38 deletions.
81 changes: 68 additions & 13 deletions 03-nosql/c-couchdb.md
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,21 @@
!SLIDE commandline incremental

## CouchDB

$ curl -X PUT http://localhost:5984/test/
{"ok":true}

$ curl -X PUT -d '{"name": "Matt"}' http://localhost:5984/test/maburke
{"ok":true,"id":"maburke",
"rev":"1-47804390369d435cb116403da935bdd5"}

$ curl http://localhost:5984/test/maburke
{"_id":"maburke","_rev":"1-47804390369d435cb116403da935bdd5",
"name":"Matt"}

!SLIDE !SLIDE


# CouchDB ## CouchDB


@@@ javascript @@@ javascript
{ {
Expand All @@ -12,24 +27,64 @@
] ]
} }


!SLIDE commandline incremental !SLIDE


# CouchDB ## CouchDB


$ curl -X PUT http://localhost:5984/test/ # _design/count
{"ok":true}


$ curl -X PUT -d '{"name": "Matt"}' http://localhost:5984/test/maburke @@@ javascript
{"ok":true,"id":"maburke", {
"rev":"1-47804390369d435cb116403da935bdd5"} "language": "javascript",
"views": {
"by_hobby": {
"map": //...
"reduce": //...
},
"by_name": {
// ...
},
}
}


$ curl http://localhost:5984/test/maburke !SLIDE
{"_id":"maburke","_rev":"1-47804390369d435cb116403da935bdd5",
"name":"Matt"} ## CouchDB

## _design/count
# by_hobby

@@@ javascript
"map": "function(doc) {
if(doc.hobbies) {
for(var i = 0; i < doc.hobbies.length; i++) {
emit(doc.hobbies[i], 1);
}
}
}"


!SLIDE !SLIDE


# CouchDB ## CouchDB
## _design/count
# by_hobby


@@@ javascript @@@ javascript
"reduce": "function(keys, values) {
return sum(values);
}"

!SLIDE

## CouchDB
# Cached map output

!SLIDE

## CouchDB
# Replication

!SLIDE

## CouchDB
# CouchApps

32 changes: 30 additions & 2 deletions 03-nosql/d-mongo.md
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,33 @@
!SLIDE !SLIDE commandline incremental
# (mongo documents)
# Mongo

$ db.streets.save({"name": "116th", "traffic": "bad"})

$ db.streets.find({"name": "116th"})
{"_id" : ObjectId( "4bb120d37e2b5a6e0477dd7b") ,
"name" : "116th" ,
"traffic" : "bad"}

$ db.streets.save({"name": "116th", "traffic": "bad", "_id": ObjectId( "4bb120d37e2b5a6e0477dd7b"), "cities": ["Carmel", "Fishers"]})

$ db.streets.save({"name": "96th", "traffic": "bad", "cities": ["Carmel", "Fishers", "Indianapolis"]})

$ db.streets.find({"cities": "Fishers"})
{"_id" : ObjectId( "4bb120d37e2b5a6e0477dd7b") ,
"name" : "116th" ,
"traffic" : "bad" ,
"cities" : ["Carmel","Fishers"]}
{"_id" : ObjectId( "4bb1218f7e2b5a6e0477dd7c") ,
"name" : "96th" ,
"traffic" : "bad" ,
"cities" : ["Carmel","Fishers","Indianapolis"]}

$ db.streets.find({"cities": "Indianapolis"})
{"_id" : ObjectId( "4bb1218f7e2b5a6e0477dd7c") ,
"name" : "96th" ,
"traffic" : "bad" ,
"cities" : ["Carmel","Fishers","Indianapolis"]}


!SLIDE !SLIDE
# (mongo map-reduce) # (mongo map-reduce)
23 changes: 0 additions & 23 deletions 04-examples/todos.md

This file was deleted.

0 comments on commit 4c78c01

Please sign in to comment.