SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Downloaden Sie, um offline zu lesen
CouchDB
w ruby'm, na przykładach
Kim jestem?




20.04.2010     Stanisław Wasiutyński   2
Plan prezentacji

             CouchDB                                  Ruby
 ●   Nierelacyjna baza danych           ●   Couchrest
 ●   RESTful JSON API                   ●   Couch_foo
 ●   Widoki (MapReduce)                 ●   Couch_potato
 ●   Replikacje                         ●   Reverse proxy



              teoria                               praktyka


20.04.2010                 Stanisław Wasiutyński              3
20.04.2010   Stanisław Wasiutyński                                                       4

                                     Źródło: http://blog.nahurst.com/visual-guide-to-nosql-systems
tu jestem




20.04.2010   Stanisław Wasiutyński                                                       5

                                     Źródło: http://blog.nahurst.com/visual-guide-to-nosql-systems
Document-Oriented
 ●   Wszystkie dane są przechowywane w formie dokumentów
     o dowolnym rozmiarze.
 ●   Każdy dokument ma unikalną nazwę, oraz posiada
     dowolną liczbę pól o unikalnej nazwie.
 ●   Każdemu polu (kluczowi) odpowiada wartość dowolnego
     typu (np. String, Integer, Array, Hash).
 ●   Na dokumentach wykonywane są operacje CRUD (Create,
     Read, Update, Delete) tylko na całym dokumencie, nigdy
     na jego fragmencie.



20.04.2010               Stanisław Wasiutyński             6
RESTful JSON API
             {
                 "_id": "fb288af72d22797f5cf68a73a7a5cb89",
                 "_rev": "12-8f531b2a273d35ecd4af58e930525e8c",
                 "couchrest-type": "Line",
                 "no": 117,
                 "begin_date": "2009/10/03",
                 "timetables": [
                   {
                     "data": {"pon-pt": [...], "sob": [...]},
                     "stop_id": "acf81f2770a21481bf0e784b7b506d38"
                   },
                   ...
                 ],
                 "updated_at": "2010/03/08 21:08:50 +0000",
                 "created_at": "2010/01/22 21:50:19 +0000"
             }



20.04.2010                          Stanisław Wasiutyński            7
RESTful JSON API


                Stwórz:                 POST /db/<id>

                Czytaj:                   GET /db/<id>

             Aktualizuj:                  PUT /db/<id>

                 Usuń:              DELETE /db/<id>




20.04.2010                 Stanisław Wasiutyński         8
20.04.2010   Stanisław Wasiutyński   9
RESTful JSON API

[~] ➔ curl http://localhost:5984/
[info] [<0.95.0>] 127.0.0.1 - - 'GET' / 200
{"couchdb":"Welcome","version":"0.11.0"}
[~] ➔ curl -X PUT http://localhost:5984/krug
[info] [<0.124.0>] 127.0.0.1 - - 'PUT' /krug 201
{"ok":true}
[~] ➔ curl -X POST http://localhost:5984/krug -d '{"Temat": "Witaj świecie!"}'
[info] [<0.216.0>] 127.0.0.1 - - 'POST' /krug 201
{"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a"}
[~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be 
> -d '{"Temat": "Witaj okrutny świecie!"}'
[info] [<0.668.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 409
{"error":"conflict","reason":"Document update conflict."}
[~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be 
> -d '{"_rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a", "Temat": "Witaj okrutny świecie!"}'
{"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"2-e51a077b62b9bfbc8faac8aff60733b4"}
[info] [<0.774.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 201
[~] ➔ curl http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be
[info] [<0.1264.0>] 127.0.0.1 - - 'GET' /krug/8cb7299cc68d35a2ca4a0c18070009be 200
{"_id":"8cb7299cc68d35a2ca4a0c18070009be","_rev":"2-e51a077b62b9bfbc8faac8aff60733b4",
"Temat":"Witaj okrutny u015bwiecie!"}
[~] ➔

    20.04.2010                           Stanisław Wasiutyński                               10
RESTful JSON API

[~] ➔ curl http://localhost:5984/
[info] [<0.95.0>] 127.0.0.1 - - 'GET' / 200
{"couchdb":"Welcome","version":"0.11.0"}
[~] ➔ curl -X PUT http://localhost:5984/krug
[info] [<0.124.0>] 127.0.0.1 - - 'PUT' /krug 201
{"ok":true}
[~] ➔ curl -X POST http://localhost:5984/krug -d '{"Temat": "Witaj świecie!"}'
[info] [<0.216.0>] 127.0.0.1 - - 'POST' /krug 201
{"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a"}
[~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be 
> -d '{"Temat": "Witaj okrutny świecie!"}'
[info] [<0.668.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 409
{"error":"conflict","reason":"Document update conflict."}
[~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be 
> -d '{"_rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a", "Temat": "Witaj okrutny świecie!"}'
{"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"2-e51a077b62b9bfbc8faac8aff60733b4"}
[info] [<0.774.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 201
[~] ➔ curl http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be
[info] [<0.1264.0>] 127.0.0.1 - - 'GET' /krug/8cb7299cc68d35a2ca4a0c18070009be 200
{"_id":"8cb7299cc68d35a2ca4a0c18070009be","_rev":"2-e51a077b62b9bfbc8faac8aff60733b4",
"Temat":"Witaj okrutny u015bwiecie!"}
[~] ➔

    20.04.2010                           Stanisław Wasiutyński                               11
RESTful JSON API

[~] ➔ curl http://localhost:5984/
[info] [<0.95.0>] 127.0.0.1 - - 'GET' / 200
{"couchdb":"Welcome","version":"0.11.0"}
[~] ➔ curl -X PUT http://localhost:5984/krug
[info] [<0.124.0>] 127.0.0.1 - - 'PUT' /krug 201
{"ok":true}
[~] ➔ curl -X POST http://localhost:5984/krug -d '{"Temat": "Witaj świecie!"}'
[info] [<0.216.0>] 127.0.0.1 - - 'POST' /krug 201
{"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a"}
[~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be 
> -d '{"Temat": "Witaj okrutny świecie!"}'
[info] [<0.668.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 409
{"error":"conflict","reason":"Document update conflict."}
[~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be 
> -d '{"_rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a", "Temat": "Witaj okrutny świecie!"}'
{"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"2-e51a077b62b9bfbc8faac8aff60733b4"}
[info] [<0.774.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 201
[~] ➔ curl http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be
[info] [<0.1264.0>] 127.0.0.1 - - 'GET' /krug/8cb7299cc68d35a2ca4a0c18070009be 200
{"_id":"8cb7299cc68d35a2ca4a0c18070009be","_rev":"2-e51a077b62b9bfbc8faac8aff60733b4",
"Temat":"Witaj okrutny u015bwiecie!"}
[~] ➔

    20.04.2010                           Stanisław Wasiutyński                               12
RESTful JSON API

[~] ➔ curl http://localhost:5984/
[info] [<0.95.0>] 127.0.0.1 - - 'GET' / 200
{"couchdb":"Welcome","version":"0.11.0"}
[~] ➔ curl -X PUT http://localhost:5984/krug
[info] [<0.124.0>] 127.0.0.1 - - 'PUT' /krug 201
{"ok":true}
[~] ➔ curl -X POST http://localhost:5984/krug -d '{"Temat": "Witaj świecie!"}'
[info] [<0.216.0>] 127.0.0.1 - - 'POST' /krug 201
{"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a"}
[~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be 
> -d '{"Temat": "Witaj okrutny świecie!"}'
[info] [<0.668.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 409
{"error":"conflict","reason":"Document update conflict."}
[~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be 
> -d '{"_rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a", "Temat": "Witaj okrutny świecie!"}'
{"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"2-e51a077b62b9bfbc8faac8aff60733b4"}
[info] [<0.774.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 201
[~] ➔ curl http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be
[info] [<0.1264.0>] 127.0.0.1 - - 'GET' /krug/8cb7299cc68d35a2ca4a0c18070009be 200
{"_id":"8cb7299cc68d35a2ca4a0c18070009be","_rev":"2-e51a077b62b9bfbc8faac8aff60733b4",
"Temat":"Witaj okrutny u015bwiecie!"}
[~] ➔

    20.04.2010                           Stanisław Wasiutyński                               13
RESTful JSON API

[~] ➔ curl http://localhost:5984/
[info] [<0.95.0>] 127.0.0.1 - - 'GET' / 200
{"couchdb":"Welcome","version":"0.11.0"}
[~] ➔ curl -X PUT http://localhost:5984/krug
[info] [<0.124.0>] 127.0.0.1 - - 'PUT' /krug 201
{"ok":true}
[~] ➔ curl -X POST http://localhost:5984/krug -d '{"Temat": "Witaj świecie!"}'
[info] [<0.216.0>] 127.0.0.1 - - 'POST' /krug 201
{"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a"}
[~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be 
> -d '{"Temat": "Witaj okrutny świecie!"}'
[info] [<0.668.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 409
{"error":"conflict","reason":"Document update conflict."}
[~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be 
> -d '{"_rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a", "Temat": "Witaj okrutny świecie!"}'
{"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"2-e51a077b62b9bfbc8faac8aff60733b4"}
[info] [<0.774.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 201
[~] ➔ curl http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be
[info] [<0.1264.0>] 127.0.0.1 - - 'GET' /krug/8cb7299cc68d35a2ca4a0c18070009be 200
{"_id":"8cb7299cc68d35a2ca4a0c18070009be","_rev":"2-e51a077b62b9bfbc8faac8aff60733b4",
"Temat":"Witaj okrutny u015bwiecie!"}
[~] ➔

    20.04.2010                           Stanisław Wasiutyński                               14
RESTful JSON API

[~] ➔ curl http://localhost:5984/
[info] [<0.95.0>] 127.0.0.1 - - 'GET' / 200
{"couchdb":"Welcome","version":"0.11.0"}
[~] ➔ curl -X PUT http://localhost:5984/krug
[info] [<0.124.0>] 127.0.0.1 - - 'PUT' /krug 201
{"ok":true}
[~] ➔ curl -X POST http://localhost:5984/krug -d '{"Temat": "Witaj świecie!"}'
[info] [<0.216.0>] 127.0.0.1 - - 'POST' /krug 201
{"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a"}
[~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be 
> -d '{"Temat": "Witaj okrutny świecie!"}'
[info] [<0.668.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 409
{"error":"conflict","reason":"Document update conflict."}
[~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be 
> -d '{"_rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a", "Temat": "Witaj okrutny świecie!"}'
{"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"2-e51a077b62b9bfbc8faac8aff60733b4"}
[info] [<0.774.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 201
[~] ➔ curl http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be
[info] [<0.1264.0>] 127.0.0.1 - - 'GET' /krug/8cb7299cc68d35a2ca4a0c18070009be 200
{"_id":"8cb7299cc68d35a2ca4a0c18070009be","_rev":"2-e51a077b62b9bfbc8faac8aff60733b4",
"Temat":"Witaj okrutny u015bwiecie!"}
[~] ➔

    20.04.2010                           Stanisław Wasiutyński                               15
Coś więcej niż wymyślny
      serwer plików.




20.04.2010      Stanisław Wasiutyński                                          16

                                        http://www.flickr.com/photos/santos/1704875109/
Widoki
 ●   Są przechowywane jako dokumenty,
 ●   definiują dowolne funkcje map i reduce,
 ●   służą do budowy wydajnych indeksów,
 ●   pozwalają na niezależne przetwarzanie pojedynczych
     dokumentów i zwrócenie ich w pożądanym formacie,
 ●   generowane równolegle, inkrementalnie i na żądanie,
 ●   brak dynamicznych zapytań („close to the metal”),
 ●   rozbudowane API.



20.04.2010                 Stanisław Wasiutyński           17
Map Reduce




GET /_design/comments/_view/cenzor?limit=11&reduce=false
GET /_design/comments/_view/cenzor?limit=11&reduce=false&
    startkey=[<id>, <rok>, <miesiąc>, <dzień>]&
    endkey=[<id>, <rok>, <miesiąc>, <dzień>+3]

GET /_design/comments/_view/cenzor?limit=11&group=true&group_level=3
GET /_design/comments/_view/cenzor?group=true&group_level=1&key=[<id>]



20.04.2010                       Stanisław Wasiutyński                   18
Replikacje
 ●    Dwustronne, inkrementalne,
 ●    replikacja podzbioru (przez filtry),
 ●    rozwiązywanie konfliktów.

                                                      korzyści
 ●    Łatwe skalowanie wszerz,
 ●    praca off-line.


     curl -X POST http://localhost:5984/_replicate -d
     {"source": "http://couch.db/remote", "target": "local"}



20.04.2010                    Stanisław Wasiutyński              19
Replikacje




20.04.2010    Stanisław Wasiutyński                                                    20

                                      http://www.slideshare.net/mlmilleratmit/20100310-miller-sts
Ruby




20.04.2010   Stanisław Wasiutyński   21
Couchrest




             Couchrest


20.04.2010      Stanisław Wasiutyński   22
20.04.2010   Stanisław Wasiutyński   23
Couch_foo


20.04.2010      Stanisław Wasiutyński   24
20.04.2010   Stanisław Wasiutyński   25
Couch_potato


20.04.2010       Stanisław Wasiutyński   26
20.04.2010   Stanisław Wasiutyński   27
em_proxy


20.04.2010     Stanisław Wasiutyński   28
20.04.2010   Stanisław Wasiutyński   29
O czym nie mówiłem?
 ●   Couchdb-Lucene – pełno-tekstowa wyszukiwarka
     dokumentów CouchDB,
 ●   Couchdb-Lounge – proxy framework do partycjonowania
     CouchDB,
 ●   CouchApps - samowystarczalne aplikacje CouchDB,
 ●   bezpieczeństwo,
 ●   binarne załączniki,
 ●   walidacja dokumentów,
 ●   BrowserCouch – CouchDB w przeglądarce.


20.04.2010                 Stanisław Wasiutyński           30
Więcej o CouchDB na:
 ●   http://couchdb.apache.org/
 ●   http://www.couch.io/
 ●   http://wiki.apache.org/couchdb/
 ●   http://books.couchdb.org/relax/


     Oraz:
 ●   http://stackoverflow.com/questions/tagged/couchdb
 ●   http://www.reddit.com/search?q=couchdb




20.04.2010                     Stanisław Wasiutyński     31
Dziękuję za uwagę.




20.04.2010        Stanisław Wasiutyński   32
Fork me:
             github.com/Stanley




20.04.2010     Stanisław Wasiutyński   33
Pytania?




20.04.2010   Stanisław Wasiutyński   34

Weitere ähnliche Inhalte

Was ist angesagt?

MongoDB全機能解説2
MongoDB全機能解説2MongoDB全機能解説2
MongoDB全機能解説2
Takahiro Inoue
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
kchodorow
 
MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤
Takahiro Inoue
 
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Arian Gutierrez
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redis
Dvir Volk
 
スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化
スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化
スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化
Taro Matsuzawa
 
MongoDB Performance Debugging
MongoDB Performance DebuggingMongoDB Performance Debugging
MongoDB Performance Debugging
MongoDB
 

Was ist angesagt? (20)

Redis - Usability and Use Cases
Redis - Usability and Use CasesRedis - Usability and Use Cases
Redis - Usability and Use Cases
 
DEF CON 23 - amit ashbel and maty siman - game of hacks
DEF CON 23 - amit ashbel and maty siman - game of hacks DEF CON 23 - amit ashbel and maty siman - game of hacks
DEF CON 23 - amit ashbel and maty siman - game of hacks
 
Back to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB ApplicationBack to Basics Webinar 2: Your First MongoDB Application
Back to Basics Webinar 2: Your First MongoDB Application
 
Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境Mac OS X Lion で作る WordPress local 環境
Mac OS X Lion で作る WordPress local 環境
 
Mongo db presentation
Mongo db presentationMongo db presentation
Mongo db presentation
 
Back to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in DocumentsBack to Basics Webinar 3 - Thinking in Documents
Back to Basics Webinar 3 - Thinking in Documents
 
Back to Basics Webinar 1 - Introduction to NoSQL
Back to Basics Webinar 1 - Introduction to NoSQLBack to Basics Webinar 1 - Introduction to NoSQL
Back to Basics Webinar 1 - Introduction to NoSQL
 
MongoDB全機能解説2
MongoDB全機能解説2MongoDB全機能解説2
MongoDB全機能解説2
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
 
MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤MongoDBで作るソーシャルデータ新解析基盤
MongoDBで作るソーシャルデータ新解析基盤
 
Redis for the Everyday Developer
Redis for the Everyday DeveloperRedis for the Everyday Developer
Redis for the Everyday Developer
 
PHP Identity and Data Security
PHP Identity and Data SecurityPHP Identity and Data Security
PHP Identity and Data Security
 
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redis
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
NoSQL & MongoDB
NoSQL & MongoDBNoSQL & MongoDB
NoSQL & MongoDB
 
スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化
スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化
スマートフォン勉強会@関東 #11 LT 5分で語る SQLite暗号化
 
MongoDB Performance Debugging
MongoDB Performance DebuggingMongoDB Performance Debugging
MongoDB Performance Debugging
 
Trimming The Cruft
Trimming The CruftTrimming The Cruft
Trimming The Cruft
 
RESTing with the new Yandex.Disk API, Clemens Аuer
RESTing with the new Yandex.Disk API, Clemens АuerRESTing with the new Yandex.Disk API, Clemens Аuer
RESTing with the new Yandex.Disk API, Clemens Аuer
 

Andere mochten auch

Art History Final
Art History FinalArt History Final
Art History Final
lcooney1
 
Brandraising Jewishly
Brandraising JewishlyBrandraising Jewishly
Brandraising Jewishly
Sarah Durham
 
Slide Show Power Point For Lis
Slide Show Power Point For LisSlide Show Power Point For Lis
Slide Show Power Point For Lis
guest884572
 
Mini Kajian Tindakan
Mini Kajian TindakanMini Kajian Tindakan
Mini Kajian Tindakan
asak
 
Unitats electriques
Unitats electriquesUnitats electriques
Unitats electriques
Avel·lí
 
Windows Presentation Foundation
Windows Presentation FoundationWindows Presentation Foundation
Windows Presentation Foundation
cieszak
 
Presentazione standard1
Presentazione standard1Presentazione standard1
Presentazione standard1
VivianaaF
 
Birthplace of country music
Birthplace of country musicBirthplace of country music
Birthplace of country music
Mdbrandon32
 
2012 – what the bleep is it all about
2012 – what the bleep is it all about2012 – what the bleep is it all about
2012 – what the bleep is it all about
Glen Tucker
 

Andere mochten auch (20)

Art History Final
Art History FinalArt History Final
Art History Final
 
Brandraising Jewishly
Brandraising JewishlyBrandraising Jewishly
Brandraising Jewishly
 
Slide Show Power Point For Lis
Slide Show Power Point For LisSlide Show Power Point For Lis
Slide Show Power Point For Lis
 
Se 2012-06 en
Se 2012-06 enSe 2012-06 en
Se 2012-06 en
 
Social Media &amp; Your Business
Social Media &amp; Your BusinessSocial Media &amp; Your Business
Social Media &amp; Your Business
 
Mini Kajian Tindakan
Mini Kajian TindakanMini Kajian Tindakan
Mini Kajian Tindakan
 
Minicurso Objective-C LinguÁgil 2011 (parte2)
Minicurso Objective-C LinguÁgil 2011 (parte2)Minicurso Objective-C LinguÁgil 2011 (parte2)
Minicurso Objective-C LinguÁgil 2011 (parte2)
 
Unitats electriques
Unitats electriquesUnitats electriques
Unitats electriques
 
Ставлю на знання
Ставлю на знанняСтавлю на знання
Ставлю на знання
 
Verb To Be
Verb To BeVerb To Be
Verb To Be
 
Тенденции рынков энергоэффективных решений для зданий
Тенденции рынков энергоэффективных решений для зданийТенденции рынков энергоэффективных решений для зданий
Тенденции рынков энергоэффективных решений для зданий
 
Windows Presentation Foundation
Windows Presentation FoundationWindows Presentation Foundation
Windows Presentation Foundation
 
Presentazione standard1
Presentazione standard1Presentazione standard1
Presentazione standard1
 
Ch 5 Motivation
Ch 5 MotivationCh 5 Motivation
Ch 5 Motivation
 
Birthplace of country music
Birthplace of country musicBirthplace of country music
Birthplace of country music
 
How2mk freind with any1 zam naim
How2mk freind with any1 zam naimHow2mk freind with any1 zam naim
How2mk freind with any1 zam naim
 
Convergence India 2013 Multi-network Forum - Verimatrix
Convergence India 2013 Multi-network Forum - VerimatrixConvergence India 2013 Multi-network Forum - Verimatrix
Convergence India 2013 Multi-network Forum - Verimatrix
 
Мониторинг рынка электроводонагревателей
Мониторинг рынка электроводонагревателейМониторинг рынка электроводонагревателей
Мониторинг рынка электроводонагревателей
 
2012 – what the bleep is it all about
2012 – what the bleep is it all about2012 – what the bleep is it all about
2012 – what the bleep is it all about
 
Emergencias medicas
Emergencias medicasEmergencias medicas
Emergencias medicas
 

Ähnlich wie Couchdb w Ruby'm

Apache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux FestApache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux Fest
Myles Braithwaite
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
Edward Capriolo
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
b_kathir
 

Ähnlich wie Couchdb w Ruby'm (20)

Apache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux FestApache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux Fest
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 Hour
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
 
Top 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platformTop 10 F5 iRules to migrate to a modern load balancing platform
Top 10 F5 iRules to migrate to a modern load balancing platform
 
Couchdb: No SQL? No driver? No problem
Couchdb: No SQL? No driver? No problemCouchdb: No SQL? No driver? No problem
Couchdb: No SQL? No driver? No problem
 
Anwendungsfaelle für Elasticsearch
Anwendungsfaelle für ElasticsearchAnwendungsfaelle für Elasticsearch
Anwendungsfaelle für Elasticsearch
 
Socket.IO
Socket.IOSocket.IO
Socket.IO
 
Finch.io - Purely Functional REST API with Finagle
Finch.io - Purely Functional REST API with FinagleFinch.io - Purely Functional REST API with Finagle
Finch.io - Purely Functional REST API with Finagle
 
Pyrax talk
Pyrax talkPyrax talk
Pyrax talk
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
 
OSCON 2011 Learning CouchDB
OSCON 2011 Learning CouchDBOSCON 2011 Learning CouchDB
OSCON 2011 Learning CouchDB
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
 
Do Zero ao Node.js - Especialização em Engenharia de Software - UFSCar
Do Zero ao Node.js - Especialização em Engenharia de Software - UFSCarDo Zero ao Node.js - Especialização em Engenharia de Software - UFSCar
Do Zero ao Node.js - Especialização em Engenharia de Software - UFSCar
 
Node.js 與 google cloud storage
Node.js 與 google cloud storageNode.js 與 google cloud storage
Node.js 與 google cloud storage
 
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
 Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
Conceptos básicos. Seminario web 2: Su primera aplicación MongoDB
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
Forbes MongoNYC 2011
Forbes MongoNYC 2011Forbes MongoNYC 2011
Forbes MongoNYC 2011
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 
Full Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLFull Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQL
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Couchdb w Ruby'm

  • 1. CouchDB w ruby'm, na przykładach
  • 2. Kim jestem? 20.04.2010 Stanisław Wasiutyński 2
  • 3. Plan prezentacji CouchDB Ruby ● Nierelacyjna baza danych ● Couchrest ● RESTful JSON API ● Couch_foo ● Widoki (MapReduce) ● Couch_potato ● Replikacje ● Reverse proxy teoria praktyka 20.04.2010 Stanisław Wasiutyński 3
  • 4. 20.04.2010 Stanisław Wasiutyński 4 Źródło: http://blog.nahurst.com/visual-guide-to-nosql-systems
  • 5. tu jestem 20.04.2010 Stanisław Wasiutyński 5 Źródło: http://blog.nahurst.com/visual-guide-to-nosql-systems
  • 6. Document-Oriented ● Wszystkie dane są przechowywane w formie dokumentów o dowolnym rozmiarze. ● Każdy dokument ma unikalną nazwę, oraz posiada dowolną liczbę pól o unikalnej nazwie. ● Każdemu polu (kluczowi) odpowiada wartość dowolnego typu (np. String, Integer, Array, Hash). ● Na dokumentach wykonywane są operacje CRUD (Create, Read, Update, Delete) tylko na całym dokumencie, nigdy na jego fragmencie. 20.04.2010 Stanisław Wasiutyński 6
  • 7. RESTful JSON API { "_id": "fb288af72d22797f5cf68a73a7a5cb89", "_rev": "12-8f531b2a273d35ecd4af58e930525e8c", "couchrest-type": "Line", "no": 117, "begin_date": "2009/10/03", "timetables": [ { "data": {"pon-pt": [...], "sob": [...]}, "stop_id": "acf81f2770a21481bf0e784b7b506d38" }, ... ], "updated_at": "2010/03/08 21:08:50 +0000", "created_at": "2010/01/22 21:50:19 +0000" } 20.04.2010 Stanisław Wasiutyński 7
  • 8. RESTful JSON API Stwórz: POST /db/<id> Czytaj: GET /db/<id> Aktualizuj: PUT /db/<id> Usuń: DELETE /db/<id> 20.04.2010 Stanisław Wasiutyński 8
  • 9. 20.04.2010 Stanisław Wasiutyński 9
  • 10. RESTful JSON API [~] ➔ curl http://localhost:5984/ [info] [<0.95.0>] 127.0.0.1 - - 'GET' / 200 {"couchdb":"Welcome","version":"0.11.0"} [~] ➔ curl -X PUT http://localhost:5984/krug [info] [<0.124.0>] 127.0.0.1 - - 'PUT' /krug 201 {"ok":true} [~] ➔ curl -X POST http://localhost:5984/krug -d '{"Temat": "Witaj świecie!"}' [info] [<0.216.0>] 127.0.0.1 - - 'POST' /krug 201 {"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a"} [~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be > -d '{"Temat": "Witaj okrutny świecie!"}' [info] [<0.668.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 409 {"error":"conflict","reason":"Document update conflict."} [~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be > -d '{"_rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a", "Temat": "Witaj okrutny świecie!"}' {"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"2-e51a077b62b9bfbc8faac8aff60733b4"} [info] [<0.774.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 201 [~] ➔ curl http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be [info] [<0.1264.0>] 127.0.0.1 - - 'GET' /krug/8cb7299cc68d35a2ca4a0c18070009be 200 {"_id":"8cb7299cc68d35a2ca4a0c18070009be","_rev":"2-e51a077b62b9bfbc8faac8aff60733b4", "Temat":"Witaj okrutny u015bwiecie!"} [~] ➔ 20.04.2010 Stanisław Wasiutyński 10
  • 11. RESTful JSON API [~] ➔ curl http://localhost:5984/ [info] [<0.95.0>] 127.0.0.1 - - 'GET' / 200 {"couchdb":"Welcome","version":"0.11.0"} [~] ➔ curl -X PUT http://localhost:5984/krug [info] [<0.124.0>] 127.0.0.1 - - 'PUT' /krug 201 {"ok":true} [~] ➔ curl -X POST http://localhost:5984/krug -d '{"Temat": "Witaj świecie!"}' [info] [<0.216.0>] 127.0.0.1 - - 'POST' /krug 201 {"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a"} [~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be > -d '{"Temat": "Witaj okrutny świecie!"}' [info] [<0.668.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 409 {"error":"conflict","reason":"Document update conflict."} [~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be > -d '{"_rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a", "Temat": "Witaj okrutny świecie!"}' {"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"2-e51a077b62b9bfbc8faac8aff60733b4"} [info] [<0.774.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 201 [~] ➔ curl http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be [info] [<0.1264.0>] 127.0.0.1 - - 'GET' /krug/8cb7299cc68d35a2ca4a0c18070009be 200 {"_id":"8cb7299cc68d35a2ca4a0c18070009be","_rev":"2-e51a077b62b9bfbc8faac8aff60733b4", "Temat":"Witaj okrutny u015bwiecie!"} [~] ➔ 20.04.2010 Stanisław Wasiutyński 11
  • 12. RESTful JSON API [~] ➔ curl http://localhost:5984/ [info] [<0.95.0>] 127.0.0.1 - - 'GET' / 200 {"couchdb":"Welcome","version":"0.11.0"} [~] ➔ curl -X PUT http://localhost:5984/krug [info] [<0.124.0>] 127.0.0.1 - - 'PUT' /krug 201 {"ok":true} [~] ➔ curl -X POST http://localhost:5984/krug -d '{"Temat": "Witaj świecie!"}' [info] [<0.216.0>] 127.0.0.1 - - 'POST' /krug 201 {"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a"} [~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be > -d '{"Temat": "Witaj okrutny świecie!"}' [info] [<0.668.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 409 {"error":"conflict","reason":"Document update conflict."} [~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be > -d '{"_rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a", "Temat": "Witaj okrutny świecie!"}' {"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"2-e51a077b62b9bfbc8faac8aff60733b4"} [info] [<0.774.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 201 [~] ➔ curl http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be [info] [<0.1264.0>] 127.0.0.1 - - 'GET' /krug/8cb7299cc68d35a2ca4a0c18070009be 200 {"_id":"8cb7299cc68d35a2ca4a0c18070009be","_rev":"2-e51a077b62b9bfbc8faac8aff60733b4", "Temat":"Witaj okrutny u015bwiecie!"} [~] ➔ 20.04.2010 Stanisław Wasiutyński 12
  • 13. RESTful JSON API [~] ➔ curl http://localhost:5984/ [info] [<0.95.0>] 127.0.0.1 - - 'GET' / 200 {"couchdb":"Welcome","version":"0.11.0"} [~] ➔ curl -X PUT http://localhost:5984/krug [info] [<0.124.0>] 127.0.0.1 - - 'PUT' /krug 201 {"ok":true} [~] ➔ curl -X POST http://localhost:5984/krug -d '{"Temat": "Witaj świecie!"}' [info] [<0.216.0>] 127.0.0.1 - - 'POST' /krug 201 {"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a"} [~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be > -d '{"Temat": "Witaj okrutny świecie!"}' [info] [<0.668.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 409 {"error":"conflict","reason":"Document update conflict."} [~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be > -d '{"_rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a", "Temat": "Witaj okrutny świecie!"}' {"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"2-e51a077b62b9bfbc8faac8aff60733b4"} [info] [<0.774.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 201 [~] ➔ curl http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be [info] [<0.1264.0>] 127.0.0.1 - - 'GET' /krug/8cb7299cc68d35a2ca4a0c18070009be 200 {"_id":"8cb7299cc68d35a2ca4a0c18070009be","_rev":"2-e51a077b62b9bfbc8faac8aff60733b4", "Temat":"Witaj okrutny u015bwiecie!"} [~] ➔ 20.04.2010 Stanisław Wasiutyński 13
  • 14. RESTful JSON API [~] ➔ curl http://localhost:5984/ [info] [<0.95.0>] 127.0.0.1 - - 'GET' / 200 {"couchdb":"Welcome","version":"0.11.0"} [~] ➔ curl -X PUT http://localhost:5984/krug [info] [<0.124.0>] 127.0.0.1 - - 'PUT' /krug 201 {"ok":true} [~] ➔ curl -X POST http://localhost:5984/krug -d '{"Temat": "Witaj świecie!"}' [info] [<0.216.0>] 127.0.0.1 - - 'POST' /krug 201 {"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a"} [~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be > -d '{"Temat": "Witaj okrutny świecie!"}' [info] [<0.668.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 409 {"error":"conflict","reason":"Document update conflict."} [~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be > -d '{"_rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a", "Temat": "Witaj okrutny świecie!"}' {"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"2-e51a077b62b9bfbc8faac8aff60733b4"} [info] [<0.774.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 201 [~] ➔ curl http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be [info] [<0.1264.0>] 127.0.0.1 - - 'GET' /krug/8cb7299cc68d35a2ca4a0c18070009be 200 {"_id":"8cb7299cc68d35a2ca4a0c18070009be","_rev":"2-e51a077b62b9bfbc8faac8aff60733b4", "Temat":"Witaj okrutny u015bwiecie!"} [~] ➔ 20.04.2010 Stanisław Wasiutyński 14
  • 15. RESTful JSON API [~] ➔ curl http://localhost:5984/ [info] [<0.95.0>] 127.0.0.1 - - 'GET' / 200 {"couchdb":"Welcome","version":"0.11.0"} [~] ➔ curl -X PUT http://localhost:5984/krug [info] [<0.124.0>] 127.0.0.1 - - 'PUT' /krug 201 {"ok":true} [~] ➔ curl -X POST http://localhost:5984/krug -d '{"Temat": "Witaj świecie!"}' [info] [<0.216.0>] 127.0.0.1 - - 'POST' /krug 201 {"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a"} [~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be > -d '{"Temat": "Witaj okrutny świecie!"}' [info] [<0.668.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 409 {"error":"conflict","reason":"Document update conflict."} [~] ➔ curl -X PUT http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be > -d '{"_rev":"1-4777d27f9e980ed1ce8cf94c0bc1d27a", "Temat": "Witaj okrutny świecie!"}' {"ok":true,"id":"8cb7299cc68d35a2ca4a0c18070009be","rev":"2-e51a077b62b9bfbc8faac8aff60733b4"} [info] [<0.774.0>] 127.0.0.1 - - 'PUT' /krug/8cb7299cc68d35a2ca4a0c18070009be 201 [~] ➔ curl http://localhost:5984/krug/8cb7299cc68d35a2ca4a0c18070009be [info] [<0.1264.0>] 127.0.0.1 - - 'GET' /krug/8cb7299cc68d35a2ca4a0c18070009be 200 {"_id":"8cb7299cc68d35a2ca4a0c18070009be","_rev":"2-e51a077b62b9bfbc8faac8aff60733b4", "Temat":"Witaj okrutny u015bwiecie!"} [~] ➔ 20.04.2010 Stanisław Wasiutyński 15
  • 16. Coś więcej niż wymyślny serwer plików. 20.04.2010 Stanisław Wasiutyński 16 http://www.flickr.com/photos/santos/1704875109/
  • 17. Widoki ● Są przechowywane jako dokumenty, ● definiują dowolne funkcje map i reduce, ● służą do budowy wydajnych indeksów, ● pozwalają na niezależne przetwarzanie pojedynczych dokumentów i zwrócenie ich w pożądanym formacie, ● generowane równolegle, inkrementalnie i na żądanie, ● brak dynamicznych zapytań („close to the metal”), ● rozbudowane API. 20.04.2010 Stanisław Wasiutyński 17
  • 18. Map Reduce GET /_design/comments/_view/cenzor?limit=11&reduce=false GET /_design/comments/_view/cenzor?limit=11&reduce=false& startkey=[<id>, <rok>, <miesiąc>, <dzień>]& endkey=[<id>, <rok>, <miesiąc>, <dzień>+3] GET /_design/comments/_view/cenzor?limit=11&group=true&group_level=3 GET /_design/comments/_view/cenzor?group=true&group_level=1&key=[<id>] 20.04.2010 Stanisław Wasiutyński 18
  • 19. Replikacje ● Dwustronne, inkrementalne, ● replikacja podzbioru (przez filtry), ● rozwiązywanie konfliktów. korzyści ● Łatwe skalowanie wszerz, ● praca off-line. curl -X POST http://localhost:5984/_replicate -d {"source": "http://couch.db/remote", "target": "local"} 20.04.2010 Stanisław Wasiutyński 19
  • 20. Replikacje 20.04.2010 Stanisław Wasiutyński 20 http://www.slideshare.net/mlmilleratmit/20100310-miller-sts
  • 21. Ruby 20.04.2010 Stanisław Wasiutyński 21
  • 22. Couchrest Couchrest 20.04.2010 Stanisław Wasiutyński 22
  • 23. 20.04.2010 Stanisław Wasiutyński 23
  • 24. Couch_foo 20.04.2010 Stanisław Wasiutyński 24
  • 25. 20.04.2010 Stanisław Wasiutyński 25
  • 26. Couch_potato 20.04.2010 Stanisław Wasiutyński 26
  • 27. 20.04.2010 Stanisław Wasiutyński 27
  • 28. em_proxy 20.04.2010 Stanisław Wasiutyński 28
  • 29. 20.04.2010 Stanisław Wasiutyński 29
  • 30. O czym nie mówiłem? ● Couchdb-Lucene – pełno-tekstowa wyszukiwarka dokumentów CouchDB, ● Couchdb-Lounge – proxy framework do partycjonowania CouchDB, ● CouchApps - samowystarczalne aplikacje CouchDB, ● bezpieczeństwo, ● binarne załączniki, ● walidacja dokumentów, ● BrowserCouch – CouchDB w przeglądarce. 20.04.2010 Stanisław Wasiutyński 30
  • 31. Więcej o CouchDB na: ● http://couchdb.apache.org/ ● http://www.couch.io/ ● http://wiki.apache.org/couchdb/ ● http://books.couchdb.org/relax/ Oraz: ● http://stackoverflow.com/questions/tagged/couchdb ● http://www.reddit.com/search?q=couchdb 20.04.2010 Stanisław Wasiutyński 31
  • 32. Dziękuję za uwagę. 20.04.2010 Stanisław Wasiutyński 32
  • 33. Fork me: github.com/Stanley 20.04.2010 Stanisław Wasiutyński 33
  • 34. Pytania? 20.04.2010 Stanisław Wasiutyński 34