Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Couchdb done, started mongo, dropped the example.

  • Loading branch information...
commit 4c78c013a0a50e4dd9a5f461b37e13b03a0e653e 1 parent a4d6981
@spraints authored
Showing with 98 additions and 38 deletions.
  1. +68 −13 03-nosql/c-couchdb.md
  2. +30 −2 03-nosql/d-mongo.md
  3. +0 −23 04-examples/todos.md
View
81 03-nosql/c-couchdb.md
@@ -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
-# CouchDB
+## CouchDB
@@@ javascript
{
@@ -12,24 +27,64 @@
]
}
-!SLIDE commandline incremental
+!SLIDE
-# CouchDB
+## CouchDB
- $ curl -X PUT http://localhost:5984/test/
- {"ok":true}
+# _design/count
- $ curl -X PUT -d '{"name": "Matt"}' http://localhost:5984/test/maburke
- {"ok":true,"id":"maburke",
- "rev":"1-47804390369d435cb116403da935bdd5"}
+ @@@ javascript
+ {
+ "language": "javascript",
+ "views": {
+ "by_hobby": {
+ "map": //...
+ "reduce": //...
+ },
+ "by_name": {
+ // ...
+ },
+ }
+ }
- $ curl http://localhost:5984/test/maburke
- {"_id":"maburke","_rev":"1-47804390369d435cb116403da935bdd5",
- "name":"Matt"}
-
+!SLIDE
+
+## 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
-# CouchDB
+## CouchDB
+## _design/count
+# by_hobby
@@@ javascript
+ "reduce": "function(keys, values) {
+ return sum(values);
+ }"
+
+!SLIDE
+
+## CouchDB
+# Cached map output
+
+!SLIDE
+
+## CouchDB
+# Replication
+
+!SLIDE
+
+## CouchDB
+# CouchApps
+
View
32 03-nosql/d-mongo.md
@@ -1,5 +1,33 @@
-!SLIDE
-# (mongo documents)
+!SLIDE commandline incremental
+
+# 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
# (mongo map-reduce)
View
23 04-examples/todos.md
@@ -1,23 +0,0 @@
-!SLIDE
-# Example story: tcpdump
-
-!SLIDE
-# Example model in RDBMS
-
-!SLIDE
-# Example model in Mongo/Couch
-
-!SLIDE
-# Example query in RDBMS
-
-!SLIDE bullets
-# Example query in Mongo
-* simple
-* map/reduce
-
-!SLIDE bullets
-# Example query in CouchDB
-* map/reduce
-
-!SLIDE
-# My comparison of couch and mongo
Please sign in to comment.
Something went wrong with that request. Please try again.