## NoSQL Discussion Points ### Failover * Master/Slave - Main Goal Data Redundancy * Automated Failover - High Availability * Good for D/R Mongo * All Data is Versioned ### Data Types * Mongo * JSON Style ```json { author: 'joe', created : new Date('01/10/2012'), title : 'Yet another blog post', text : 'Here is the text...', tags : [ 'example', 'joe' ], comments : [ { author: 'jim', comment: 'I disagree' }, { author: 'nancy', comment: 'Good post' } ] } ``` * Redis * Strings, Lists, Sets, Hashsets * Everything is Key/Value * Supports complex operations ### API * Mongo * SQL Like (Native) * Reduce (JS) * Scala Support * Node Support * Supports notion of Indexs * Lacks Tx Support (Not an issue, b/c Akka wraps db calls in STM) Sample Query ```javascript db.users.find({id:20202}) // Find User with id .. db.users.find() // Find All db.users.find({id:20202}, {first:1, last:1}) / Find first,last ... ``` ```scala val mongoColl = MongoConnection()("casbah_test")("test_data") val user1 = MongoDBObject("user" -> "steve", "email" -> "steve@gmail.com") val user2 = MongoDBObject("user" -> "someOtherUser") mongoColl += user1 mongoColl += user2 mongoColl.find() // com.mongodb.casbah.MongoCursor = // MongoCursor{Iterator[DBObject] with 2 objects.} for { x <- mongoColl} yield x /* Iterable[com.mongodb.DBObject] = List( { "_id" : { "$oid" : "4c3e2bec521142c87cc10fff"} , "user" : "steve" , "email" : "steve@gmail.com"}, { "_id" : { "$oid" : "4c3e2bec521142c87dc10fff"} , "user" : "someOtherUser"} ) */ ``` * Mongo ```scala r.set("key", "some value") r.get("key") // Option[String] = Some(some value) r.hmset("hash", Map("field1" -> "1", "field2" -> 2)) r.hmget[String,String]("hash", "field1", "field2") // Option[Map[String,String]] = Some(Map(field1 -> 1, field2 -> 2)) ```` ### Other * Mongo is Hugely Popular