Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

CouchDB: A NoSQL database

1,636 views

Published on

Published in: Technology
  • Be the first to comment

CouchDB: A NoSQL database

  1. 1. Couch DB a NoSql databaseFederico Ramallo
  2. 2. About me Rails developer Ruby mentor Certified Scrum Master Motorcyclist Co-founder of Tangosource.
  3. 3. What is couchdb? JSON document server Accesible ONLY via HTTP RESTful JSON API is schema free Distributed, supports replication Scales a LOT Can take 2k request / second VS Ruby that can take 15/20 request / second
  4. 4. How to query the database? What is a View? Is a pre calculated query on the database using map reduce Use javascript functions example of a map functionfunction(doc) { if(doc.date && doc.title) { emit(doc.date, doc.title); }} This is a map function that allows you to filter by all records that has a title field. a.k.a filter by record type Is schema free, so could use a type field or NOT
  5. 5. How to use it with ruby? There are several rubygems couchrest https://rubygems.org/gems/couchrest couch_potato https://github.com/langalex/couch_potato couch_foo https://github.com/georgepalmer/couch_foo couchDB-Ruby http://rubyforge.org/projects/couchdb/ The more they try to abstract from couch, the less powerfull they are. I recommend couchrest because: Is light Is simillar to couch api
  6. 6. Couchrest ExampleCouchRest example using couchrest gem require couchrest # Connect / create to the database server = CouchRest.new("http://localhost:5984") db = server.create_db(my-db) # Save documents db.save({_id => my-doc, will-exist => here}) # Get documents doc = db.get(my-doc); doc[will-exist] #=> here db.delete(doc)
  7. 7. How you could use it for bigapplications Move couchdb as a web server Use Ruby for everything else hanging for the _changes feed Use js to interact. Why? Because is super fast Because the browser can have the info locally
  8. 8. Use JS frameworks for thefrontend! Examples: Backbone.js Sproutcore Capuccino Titanum Ext.js The new model is: Browser - Couchdb - Ruby
  9. 9. What about ruby? Use it as backend to run background tasks like: Sending emails Authentication
  10. 10. ThanksThanks! framallo@gmail.com

×