SlideShare a Scribd company logo
1 of 48
Download to read offline
couchdb, ruby,
and you.


   will leinweber — bitfission.com — merge.fm — @leinweber
will leinweber



   will leinweber — bitfission.com — merge.fm — @leinweber
couchdb



   will leinweber — bitfission.com — merge.fm — @leinweber
will leinweber — bitfission.com — merge.fm — @leinweber
will leinweber — bitfission.com — merge.fm — @leinweber
documents



   will leinweber — bitfission.com — merge.fm — @leinweber
json



       will leinweber — bitfission.com — merge.fm — @leinweber
rich documents



   will leinweber — bitfission.com — merge.fm — @leinweber
{
    "_id": "will",
    "_rev": "3-4352629382",
    "fullname": "Will Leinweber",
    "email": "will@bitfission.com",
    "sites": [
      {"blog": "bitfission.com", "hits": 42},
      {"github": "github.com/will"},
      {"twitter": "twitter.com/leinweber"},
      {"company": "merge.fm"}
    ]
}




         will leinweber — bitfission.com — merge.fm — @leinweber
schemaless



   will leinweber — bitfission.com — merge.fm — @leinweber
http api



   will leinweber — bitfission.com — merge.fm — @leinweber
restful



    will leinweber — bitfission.com — merge.fm — @leinweber
~% curl localhost:5984/appdb/docid
{"_id":"docid","_rev":"2-3779119708","look":"at all
this data","its_awesome":true}




             will leinweber — bitfission.com — merge.fm — @leinweber
~% curl localhost:5984/appdb/docid -i
HTTP/1.1 200 OK
Server: CouchDB/0.11.0 (Erlang OTP/R13B)
Etag: "2-3779119708"
Date: Wed, 28 Apr 2010 06:46:42 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 83
Cache-Control: must-revalidate




        will leinweber — bitfission.com — merge.fm — @leinweber
caching



   will leinweber — bitfission.com — merge.fm — @leinweber
clustering



    will leinweber — bitfission.com — merge.fm — @leinweber
replication



   will leinweber — bitfission.com — merge.fm — @leinweber
couchapps!



   will leinweber — bitfission.com — merge.fm — @leinweber
views



   will leinweber — bitfission.com — merge.fm — @leinweber
javascript
map/reduce


   will leinweber — bitfission.com — merge.fm — @leinweber
map


  will leinweber — bitfission.com — merge.fm — @leinweber
bit.ly/jscouchdb
example


   will leinweber — bitfission.com — merge.fm — @leinweber
{"_id":1,"name":"fish.jpg","user":"bob","camera":"nikon",
    "info":{"width":100,"height":200,"size":12345},"tags":["tuna","shark"]}
{"_id":2,"name":"trees.jpg","user":"john","camera":"canon",
    "info":{"width":30,"height":250,"size":32091},"tags":["oak"]}
{"_id":3,"name":"snow.png","user":"john","camera":"canon",
    "info":{"width":64,"height":64,"size":1253},"tags":["tahoe","powder"]}
{"_id":4,"name":"hawaii.png","user":"john","camera":"nikon",
    "info":{"width":128,"height":64,"size":92834},"tags":["maui","tuna"]}
{"_id":5,"name":"hawaii.gif","user":"bob","camera":"canon",
    "info":{"width":320,"height":128,"size":49287},"tags":["maui"]}
{"_id":6,"name":"island.gif","user":"zztop","camera":"nikon",
    "info":{"width":640,"height":480,"size":50398},"tags":["maui"]}




                  will leinweber — bitfission.com — merge.fm — @leinweber
function(doc) {
  emit(doc.user, null);
}

       {
           "total_rows": 6,
           "rows": [
               {"id":"1","key":"bob","value":null},
               {"id":"5","key":"bob","value":null},
               {"id":"2","key":"john","value":null},
               {"id":"3","key":"john","value":null},
               {"id":"4","key":"john","value":null},
               {"id":"6","key":"zztop","value":null}
            ]
       }




                will leinweber — bitfission.com — merge.fm — @leinweber
function(doc) {
  emit(doc.name.match(/w+.(w{3})/)[1], null);
}



         {
             "total_rows": 6,
             "rows": [
                 {"id":"5","key":"gif","value":null},
                 {"id":"6","key":"gif","value":null},
                 {"id":"1","key":"jpg","value":null},
                 {"id":"2","key":"jpg","value":null},
                 {"id":"3","key":"png","value":null},
                 {"id":"4","key":"png","value":null}
              ]
         }




               will leinweber — bitfission.com — merge.fm — @leinweber
function(doc) {
  emit(doc.name.match(/w+.(w{3})/)[1], null);
}


  ?key="jpg"

         {
             "total_rows": 2,
             "rows": [
                 {"id":"1","key":"jpg","value":null},
                 {"id":"2","key":"jpg","value":null},
              ]
         }




               will leinweber — bitfission.com — merge.fm — @leinweber
//reduce
//map

function(doc) {                                function(keys,values,rereduce) {
  emit("size",doc.info.size);                    return sum(values);
}                                              }



id       key     value
 1      "size"   12345                  {
 2      "size"   32091                      "rows": [
                         reduced
 3      "size"   1253                           {"key":"size","value":238208}
                         238208
 4      "size"   92834                       ]
 5      "size"   49287                  }
 6      "size"   50398




                    will leinweber — bitfission.com — merge.fm — @leinweber
//reduce
//map

function(doc) {                               function(keys,values,rereduce) {
  emit(doc.user, 1);                            return sum(values);
}                                             }



id       key value reduced             {
 1      "bob"   1                          "rows": [
 2      "bob"   1    2                         {"key":"bob","value":2},
 3      "john" 1                               {"key":"john","value":3},
 4      "john" 1     3                         {"key":"zztop","value":1}
 5      "john" 1                            ]
 6      "zztop" 1    1                 }




                   will leinweber — bitfission.com — merge.fm — @leinweber
last example:
complex keys


   will leinweber — bitfission.com — merge.fm — @leinweber
{"_id":1,"name":"fish.jpg","user":"bob","camera":"nikon",
    "info":{"width":100,"height":200,"size":12345},"tags":["tuna","shark"]}
{"_id":2,"name":"trees.jpg","user":"john","camera":"canon",
    "info":{"width":30,"height":250,"size":32091},"tags":["oak"]}
{"_id":3,"name":"snow.png","user":"john","camera":"canon",
    "info":{"width":64,"height":64,"size":1253},"tags":["tahoe","powder"]}
{"_id":4,"name":"hawaii.png","user":"john","camera":"nikon",
    "info":{"width":128,"height":64,"size":92834},"tags":["maui","tuna"]}
{"_id":5,"name":"hawaii.gif","user":"bob","camera":"canon",
    "info":{"width":320,"height":128,"size":49287},"tags":["maui"]}
{"_id":6,"name":"island.gif","user":"zztop","camera":"nikon",
    "info":{"width":640,"height":480,"size":50398},"tags":["maui"]}




                   will leinweber — bitfission.com — merge.fm — @leinweber
//map                                           //reduce
function(doc) {                                 function(keys,values,rereduce){
  emit([doc.user,doc.camera],1);                  return sum(values);
}                                               }



id key            value reduced {
                                  "rows": [
5 ["bob","canon"]    1     1
                                   {"key":["bob","canon"],"value":1},
1 ["bob","nikon"]    1     1        {"key":["bob","nikon"],"value":1},
2 ["john","canon"] 1                {"key":["john","canon"],"value":2},
                           2
3 ["john","canon"] 1                {"key":["john","nikon"],"value":1},
4 ["john","nikon"] 1       1        {"key":["zztop","nikon"],"value":1}
                                   ]
6 ["zztop","nikon"] 1      1
                                         }




                 will leinweber — bitfission.com — merge.fm — @leinweber
//map                                            //reduce
function(doc) {                                  function(keys,values,rereduce){
  emit([doc.user,doc.camera],1);                   return sum(values);
}                                                }


                  ?startkey=[“bob”]&endkey=[“bob”,{}]

              {
                "rows": [
                 {"key":["bob","canon"],"value":1},
                  {"key":["bob","nikon"],"value":1},
                 ]
              }




                  will leinweber — bitfission.com — merge.fm — @leinweber
views are saved
b+ trees


   will leinweber — bitfission.com — merge.fm — @leinweber
updated when
accessed


   will leinweber — bitfission.com — merge.fm — @leinweber
updated
incrementally


   will leinweber — bitfission.com — merge.fm — @leinweber
couchrest



   will leinweber — bitfission.com — merge.fm — @leinweber
will leinweber — bitfission.com — merge.fm — @leinweber
couchrest core



   will leinweber — bitfission.com — merge.fm — @leinweber
DB = CouchRest.database!("temps")

DB.save_doc "_id" => "room1", "temps" => [34]
#=> {"rev"=>"1-3b4f6c5218621d8876", "id"=>"room1", "ok"=>true}

room = DB.get "room1"
#=> {"temps"=>[34], "_rev"=>"1-3b4f6c5218621", "_id"=>"room1"}
room["temps"] << 35 << 25 << 33 << 25

room.save
#=> {"temps"=>[34,35,25,33,25],"_rev"=>"2-1d15c4a8a","_id"=>"room1"}




                will leinweber — bitfission.com — merge.fm — @leinweber
DB.view("temps/temp", :key=>25)
#=> {"total_rows"=>5, "rows"=>[
        {"id"=>"room1", "value"=>{...}, "key"=>25}
   ]}




             will leinweber — bitfission.com — merge.fm — @leinweber
Extended
Document


   will leinweber — bitfission.com — merge.fm — @leinweber
class User < CouchRest::ExtendedDocument
  property :name
  property :email
  property :posts, :default => [], :accessible => true
  timestamps!
  view_by :name
  view_by :post_ids,
    :map => %Q("function(doc) {
      if (doc['couchrest-type']=='User' && doc.post_ids){...)
  validates_with_method :name, :valid_name?
  validates_presence_of :email
  before_save :update_posts
end




              will leinweber — bitfission.com — merge.fm — @leinweber
get couchdb



   will leinweber — bitfission.com — merge.fm — @leinweber
homebrew
couchdbx
build

  will leinweber — bitfission.com — merge.fm — @leinweber
links



    will leinweber — bitfission.com — merge.fm — @leinweber
couchdb.apache.org
books.couchdb.org
github.com/couchrest
bit.ly/jscouchdb

    will leinweber — bitfission.com — merge.fm — @leinweber
thanks



   will leinweber — bitfission.com — merge.fm — @leinweber
will leinweber — bitfission.com — merge.fm — @leinweber

More Related Content

What's hot

MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)MongoSF
 
Inside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source DatabaseInside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source DatabaseMike Dirolf
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
 
How to use MongoDB with CakePHP
How to use MongoDB with CakePHPHow to use MongoDB with CakePHP
How to use MongoDB with CakePHPichikaway
 
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...MongoDB
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica SetsMongoDB
 
A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009Jordan Baker
 
Dive into kotlins coroutines
Dive into kotlins coroutinesDive into kotlins coroutines
Dive into kotlins coroutinesFreddie Wang
 
MongoDB World 2019: How to Keep an Average API Response Time Less than 5ms wi...
MongoDB World 2019: How to Keep an Average API Response Time Less than 5ms wi...MongoDB World 2019: How to Keep an Average API Response Time Less than 5ms wi...
MongoDB World 2019: How to Keep an Average API Response Time Less than 5ms wi...MongoDB
 
(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and ProfitOlaf Alders
 
집단지성 프로그래밍 08-가격모델링
집단지성 프로그래밍 08-가격모델링집단지성 프로그래밍 08-가격모델링
집단지성 프로그래밍 08-가격모델링Kwang Woo NAM
 
mobl - model-driven engineering lecture
mobl - model-driven engineering lecturemobl - model-driven engineering lecture
mobl - model-driven engineering lecturezefhemel
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기JangHyuk You
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1Ke Wei Louis
 
밑바닥부터 시작하는 의료 AI
밑바닥부터 시작하는 의료 AI밑바닥부터 시작하는 의료 AI
밑바닥부터 시작하는 의료 AINAVER Engineering
 

What's hot (20)

MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDBMongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
 
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
Map/reduce, geospatial indexing, and other cool features (Kristina Chodorow)
 
FalcorJS
FalcorJSFalcorJS
FalcorJS
 
MongoDB dessi-codemotion
MongoDB dessi-codemotionMongoDB dessi-codemotion
MongoDB dessi-codemotion
 
Inside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source DatabaseInside MongoDB: the Internals of an Open-Source Database
Inside MongoDB: the Internals of an Open-Source Database
 
Potential Friend Finder
Potential Friend FinderPotential Friend Finder
Potential Friend Finder
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
How to use MongoDB with CakePHP
How to use MongoDB with CakePHPHow to use MongoDB with CakePHP
How to use MongoDB with CakePHP
 
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...
MongoDB World 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pipeline Em...
 
Webinar: Replication and Replica Sets
Webinar: Replication and Replica SetsWebinar: Replication and Replica Sets
Webinar: Replication and Replica Sets
 
A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009A Taste of Python - Devdays Toronto 2009
A Taste of Python - Devdays Toronto 2009
 
Dive into kotlins coroutines
Dive into kotlins coroutinesDive into kotlins coroutines
Dive into kotlins coroutines
 
Kotlin coroutines
Kotlin coroutines Kotlin coroutines
Kotlin coroutines
 
MongoDB World 2019: How to Keep an Average API Response Time Less than 5ms wi...
MongoDB World 2019: How to Keep an Average API Response Time Less than 5ms wi...MongoDB World 2019: How to Keep an Average API Response Time Less than 5ms wi...
MongoDB World 2019: How to Keep an Average API Response Time Less than 5ms wi...
 
(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit
 
집단지성 프로그래밍 08-가격모델링
집단지성 프로그래밍 08-가격모델링집단지성 프로그래밍 08-가격모델링
집단지성 프로그래밍 08-가격모델링
 
mobl - model-driven engineering lecture
mobl - model-driven engineering lecturemobl - model-driven engineering lecture
mobl - model-driven engineering lecture
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기
 
Super Advanced Python –act1
Super Advanced Python –act1Super Advanced Python –act1
Super Advanced Python –act1
 
밑바닥부터 시작하는 의료 AI
밑바닥부터 시작하는 의료 AI밑바닥부터 시작하는 의료 AI
밑바닥부터 시작하는 의료 AI
 

Similar to CouchDB @ red dirt ruby conference

Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go ProgrammingLin Yo-An
 
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"South Tyrol Free Software Conference
 
HTML5 and CSS3 Refresher
HTML5 and CSS3 RefresherHTML5 and CSS3 Refresher
HTML5 and CSS3 RefresherIvano Malavolta
 
ELK Stack - Turn boring logfiles into sexy dashboard
ELK Stack - Turn boring logfiles into sexy dashboardELK Stack - Turn boring logfiles into sexy dashboard
ELK Stack - Turn boring logfiles into sexy dashboardGeorg Sorst
 
Aggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichAggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichNorberto Leite
 
d3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlind3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in BerlinToshiaki Katayama
 
CouchDB at JAOO Århus 2009
CouchDB at JAOO Århus 2009CouchDB at JAOO Århus 2009
CouchDB at JAOO Århus 2009Jason Davies
 
Webinar: Data Processing and Aggregation Options
Webinar: Data Processing and Aggregation OptionsWebinar: Data Processing and Aggregation Options
Webinar: Data Processing and Aggregation OptionsMongoDB
 
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)Adam Darowski
 
Modeling JSON data for NoSQL document databases
Modeling JSON data for NoSQL document databasesModeling JSON data for NoSQL document databases
Modeling JSON data for NoSQL document databasesRyan CrawCour
 
The Aggregation Framework
The Aggregation FrameworkThe Aggregation Framework
The Aggregation FrameworkMongoDB
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsMongoDB
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天tblanlan
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-futureyiming he
 
Programming with Python and PostgreSQL
Programming with Python and PostgreSQLProgramming with Python and PostgreSQL
Programming with Python and PostgreSQLPeter Eisentraut
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDBNate Abele
 

Similar to CouchDB @ red dirt ruby conference (20)

Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
 
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
SFScon17 - Patrick Puecher: "Exploring data with Elasticsearch and Kibana"
 
HTML5 and CSS3 Refresher
HTML5 and CSS3 RefresherHTML5 and CSS3 Refresher
HTML5 and CSS3 Refresher
 
ELK Stack - Turn boring logfiles into sexy dashboard
ELK Stack - Turn boring logfiles into sexy dashboardELK Stack - Turn boring logfiles into sexy dashboard
ELK Stack - Turn boring logfiles into sexy dashboard
 
Aggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days MunichAggregation Framework MongoDB Days Munich
Aggregation Framework MongoDB Days Munich
 
Tabledown
TabledownTabledown
Tabledown
 
d3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlind3sparql.js demo at SWAT4LS 2014 in Berlin
d3sparql.js demo at SWAT4LS 2014 in Berlin
 
CouchDB at JAOO Århus 2009
CouchDB at JAOO Århus 2009CouchDB at JAOO Århus 2009
CouchDB at JAOO Århus 2009
 
Webinar: Data Processing and Aggregation Options
Webinar: Data Processing and Aggregation OptionsWebinar: Data Processing and Aggregation Options
Webinar: Data Processing and Aggregation Options
 
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
 
MongoDB
MongoDBMongoDB
MongoDB
 
Modeling JSON data for NoSQL document databases
Modeling JSON data for NoSQL document databasesModeling JSON data for NoSQL document databases
Modeling JSON data for NoSQL document databases
 
The Aggregation Framework
The Aggregation FrameworkThe Aggregation Framework
The Aggregation Framework
 
Mongo db presentation
Mongo db presentationMongo db presentation
Mongo db presentation
 
Webinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev TeamsWebinar: General Technical Overview of MongoDB for Dev Teams
Webinar: General Technical Overview of MongoDB for Dev Teams
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-future
 
Latinoware
LatinowareLatinoware
Latinoware
 
Programming with Python and PostgreSQL
Programming with Python and PostgreSQLProgramming with Python and PostgreSQL
Programming with Python and PostgreSQL
 
Building Apps with MongoDB
Building Apps with MongoDBBuilding Apps with MongoDB
Building Apps with MongoDB
 

Recently uploaded

(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?Paolo Missier
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistandanishmna97
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Paige Cruz
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxFIDO Alliance
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxjbellis
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Skynet Technologies
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTopCSSGallery
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdfMuhammad Subhan
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingScyllaDB
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 

Recently uploaded (20)

(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
(Explainable) Data-Centric AI: what are you explaininhg, and to whom?
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistan
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
“Iamnobody89757” Understanding the Mysterious of Digital Identity.pdf
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 

CouchDB @ red dirt ruby conference

  • 1. couchdb, ruby, and you. will leinweber — bitfission.com — merge.fm — @leinweber
  • 2. will leinweber will leinweber — bitfission.com — merge.fm — @leinweber
  • 3. couchdb will leinweber — bitfission.com — merge.fm — @leinweber
  • 4. will leinweber — bitfission.com — merge.fm — @leinweber
  • 5. will leinweber — bitfission.com — merge.fm — @leinweber
  • 6. documents will leinweber — bitfission.com — merge.fm — @leinweber
  • 7. json will leinweber — bitfission.com — merge.fm — @leinweber
  • 8. rich documents will leinweber — bitfission.com — merge.fm — @leinweber
  • 9. { "_id": "will", "_rev": "3-4352629382", "fullname": "Will Leinweber", "email": "will@bitfission.com", "sites": [ {"blog": "bitfission.com", "hits": 42}, {"github": "github.com/will"}, {"twitter": "twitter.com/leinweber"}, {"company": "merge.fm"} ] } will leinweber — bitfission.com — merge.fm — @leinweber
  • 10. schemaless will leinweber — bitfission.com — merge.fm — @leinweber
  • 11. http api will leinweber — bitfission.com — merge.fm — @leinweber
  • 12. restful will leinweber — bitfission.com — merge.fm — @leinweber
  • 13. ~% curl localhost:5984/appdb/docid {"_id":"docid","_rev":"2-3779119708","look":"at all this data","its_awesome":true} will leinweber — bitfission.com — merge.fm — @leinweber
  • 14. ~% curl localhost:5984/appdb/docid -i HTTP/1.1 200 OK Server: CouchDB/0.11.0 (Erlang OTP/R13B) Etag: "2-3779119708" Date: Wed, 28 Apr 2010 06:46:42 GMT Content-Type: text/plain;charset=utf-8 Content-Length: 83 Cache-Control: must-revalidate will leinweber — bitfission.com — merge.fm — @leinweber
  • 15. caching will leinweber — bitfission.com — merge.fm — @leinweber
  • 16. clustering will leinweber — bitfission.com — merge.fm — @leinweber
  • 17. replication will leinweber — bitfission.com — merge.fm — @leinweber
  • 18. couchapps! will leinweber — bitfission.com — merge.fm — @leinweber
  • 19. views will leinweber — bitfission.com — merge.fm — @leinweber
  • 20. javascript map/reduce will leinweber — bitfission.com — merge.fm — @leinweber
  • 21. map will leinweber — bitfission.com — merge.fm — @leinweber
  • 22. bit.ly/jscouchdb example will leinweber — bitfission.com — merge.fm — @leinweber
  • 23. {"_id":1,"name":"fish.jpg","user":"bob","camera":"nikon", "info":{"width":100,"height":200,"size":12345},"tags":["tuna","shark"]} {"_id":2,"name":"trees.jpg","user":"john","camera":"canon", "info":{"width":30,"height":250,"size":32091},"tags":["oak"]} {"_id":3,"name":"snow.png","user":"john","camera":"canon", "info":{"width":64,"height":64,"size":1253},"tags":["tahoe","powder"]} {"_id":4,"name":"hawaii.png","user":"john","camera":"nikon", "info":{"width":128,"height":64,"size":92834},"tags":["maui","tuna"]} {"_id":5,"name":"hawaii.gif","user":"bob","camera":"canon", "info":{"width":320,"height":128,"size":49287},"tags":["maui"]} {"_id":6,"name":"island.gif","user":"zztop","camera":"nikon", "info":{"width":640,"height":480,"size":50398},"tags":["maui"]} will leinweber — bitfission.com — merge.fm — @leinweber
  • 24. function(doc) { emit(doc.user, null); } { "total_rows": 6, "rows": [ {"id":"1","key":"bob","value":null}, {"id":"5","key":"bob","value":null}, {"id":"2","key":"john","value":null}, {"id":"3","key":"john","value":null}, {"id":"4","key":"john","value":null}, {"id":"6","key":"zztop","value":null} ] } will leinweber — bitfission.com — merge.fm — @leinweber
  • 25. function(doc) { emit(doc.name.match(/w+.(w{3})/)[1], null); } { "total_rows": 6, "rows": [ {"id":"5","key":"gif","value":null}, {"id":"6","key":"gif","value":null}, {"id":"1","key":"jpg","value":null}, {"id":"2","key":"jpg","value":null}, {"id":"3","key":"png","value":null}, {"id":"4","key":"png","value":null} ] } will leinweber — bitfission.com — merge.fm — @leinweber
  • 26. function(doc) { emit(doc.name.match(/w+.(w{3})/)[1], null); } ?key="jpg" { "total_rows": 2, "rows": [ {"id":"1","key":"jpg","value":null}, {"id":"2","key":"jpg","value":null}, ] } will leinweber — bitfission.com — merge.fm — @leinweber
  • 27. //reduce //map function(doc) { function(keys,values,rereduce) { emit("size",doc.info.size); return sum(values); } } id key value 1 "size" 12345 { 2 "size" 32091     "rows": [ reduced 3 "size" 1253         {"key":"size","value":238208} 238208 4 "size" 92834      ] 5 "size" 49287 } 6 "size" 50398 will leinweber — bitfission.com — merge.fm — @leinweber
  • 28. //reduce //map function(doc) { function(keys,values,rereduce) { emit(doc.user, 1); return sum(values); } } id key value reduced { 1 "bob" 1     "rows": [ 2 "bob" 1 2         {"key":"bob","value":2}, 3 "john" 1         {"key":"john","value":3}, 4 "john" 1 3         {"key":"zztop","value":1} 5 "john" 1      ] 6 "zztop" 1 1 } will leinweber — bitfission.com — merge.fm — @leinweber
  • 29. last example: complex keys will leinweber — bitfission.com — merge.fm — @leinweber
  • 30. {"_id":1,"name":"fish.jpg","user":"bob","camera":"nikon", "info":{"width":100,"height":200,"size":12345},"tags":["tuna","shark"]} {"_id":2,"name":"trees.jpg","user":"john","camera":"canon", "info":{"width":30,"height":250,"size":32091},"tags":["oak"]} {"_id":3,"name":"snow.png","user":"john","camera":"canon", "info":{"width":64,"height":64,"size":1253},"tags":["tahoe","powder"]} {"_id":4,"name":"hawaii.png","user":"john","camera":"nikon", "info":{"width":128,"height":64,"size":92834},"tags":["maui","tuna"]} {"_id":5,"name":"hawaii.gif","user":"bob","camera":"canon", "info":{"width":320,"height":128,"size":49287},"tags":["maui"]} {"_id":6,"name":"island.gif","user":"zztop","camera":"nikon", "info":{"width":640,"height":480,"size":50398},"tags":["maui"]} will leinweber — bitfission.com — merge.fm — @leinweber
  • 31. //map //reduce function(doc) { function(keys,values,rereduce){ emit([doc.user,doc.camera],1); return sum(values); } } id key value reduced { "rows": [ 5 ["bob","canon"] 1 1    {"key":["bob","canon"],"value":1}, 1 ["bob","nikon"] 1 1     {"key":["bob","nikon"],"value":1}, 2 ["john","canon"] 1     {"key":["john","canon"],"value":2}, 2 3 ["john","canon"] 1     {"key":["john","nikon"],"value":1}, 4 ["john","nikon"] 1 1     {"key":["zztop","nikon"],"value":1}    ] 6 ["zztop","nikon"] 1 1 } will leinweber — bitfission.com — merge.fm — @leinweber
  • 32. //map //reduce function(doc) { function(keys,values,rereduce){ emit([doc.user,doc.camera],1); return sum(values); } } ?startkey=[“bob”]&endkey=[“bob”,{}] { "rows": [    {"key":["bob","canon"],"value":1},     {"key":["bob","nikon"],"value":1},    ] } will leinweber — bitfission.com — merge.fm — @leinweber
  • 33. views are saved b+ trees will leinweber — bitfission.com — merge.fm — @leinweber
  • 34. updated when accessed will leinweber — bitfission.com — merge.fm — @leinweber
  • 35. updated incrementally will leinweber — bitfission.com — merge.fm — @leinweber
  • 36. couchrest will leinweber — bitfission.com — merge.fm — @leinweber
  • 37. will leinweber — bitfission.com — merge.fm — @leinweber
  • 38. couchrest core will leinweber — bitfission.com — merge.fm — @leinweber
  • 39. DB = CouchRest.database!("temps") DB.save_doc "_id" => "room1", "temps" => [34] #=> {"rev"=>"1-3b4f6c5218621d8876", "id"=>"room1", "ok"=>true} room = DB.get "room1" #=> {"temps"=>[34], "_rev"=>"1-3b4f6c5218621", "_id"=>"room1"} room["temps"] << 35 << 25 << 33 << 25 room.save #=> {"temps"=>[34,35,25,33,25],"_rev"=>"2-1d15c4a8a","_id"=>"room1"} will leinweber — bitfission.com — merge.fm — @leinweber
  • 40. DB.view("temps/temp", :key=>25) #=> {"total_rows"=>5, "rows"=>[ {"id"=>"room1", "value"=>{...}, "key"=>25} ]} will leinweber — bitfission.com — merge.fm — @leinweber
  • 41. Extended Document will leinweber — bitfission.com — merge.fm — @leinweber
  • 42. class User < CouchRest::ExtendedDocument property :name property :email property :posts, :default => [], :accessible => true timestamps! view_by :name view_by :post_ids, :map => %Q("function(doc) { if (doc['couchrest-type']=='User' && doc.post_ids){...) validates_with_method :name, :valid_name? validates_presence_of :email before_save :update_posts end will leinweber — bitfission.com — merge.fm — @leinweber
  • 43. get couchdb will leinweber — bitfission.com — merge.fm — @leinweber
  • 44. homebrew couchdbx build will leinweber — bitfission.com — merge.fm — @leinweber
  • 45. links will leinweber — bitfission.com — merge.fm — @leinweber
  • 46. couchdb.apache.org books.couchdb.org github.com/couchrest bit.ly/jscouchdb will leinweber — bitfission.com — merge.fm — @leinweber
  • 47. thanks will leinweber — bitfission.com — merge.fm — @leinweber
  • 48. will leinweber — bitfission.com — merge.fm — @leinweber

Editor's Notes