Exploding the internet

With jQuery and Couch DB

http://gul.ly/h6

http://htmlten.com/slides

OMG, This presentation is an HTML5 website

Boaz Sender

Bocoup 200

What is CouchDB?

What are we going to talk about?

Why CouchDB?

Eventual consistency

Setting up couch on the server

Interacting with CouchDB

Using JavaScript in the client

Make a database

  $.ajax({
    url: 'http://htmlten.com/db/couchdemo/', 
    type: 'PUT',
    success: function(response){
    	console.log(response);
    }
  });

Get the database

  $.ajax({
    url: 'http://htmlten.com/db/couchdemo/', 
    type: 'GET',
    success: function(response){
      console.log(response);
    }
  });

Write a record

  var newRecordId = '1',
  newRecord   = {
    //'_id': '1',
    'firstname' : 'boaz',
    'lastname'  : 'sender',
    'twitterhandle' : '@boazsender',
    'height'        : '72'
  };
  
  $.ajax({
    url: 'http://htmlten.com/db/couchdemo/' + newRecordId, 
    type: 'PUT',
    data: JSON.stringify(newRecord),
    dataType: 'JSON',
    success: function(response){
      console.log(response)
    }
  });

Get a record

	var recordId = '1';
	$.ajax({
      url: 'http://htmlten.com/db/couchdemo/' + recordId, 
  	  type: 'GET',
      success: function(response){
	      console.log(response)
      }
	});

Writing views

Getting your view data

  $.ajax({
    url: 'http://htmlten.com/db/couchdemo/_design/heights/_view/users_by_height', 
    type: 'GET',
    success: function(response){
    	console.log(response)
    }
  });

Use Cases

Questions

Thank You