friday, april 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/couchdb.pdf · this is couchdb damien...

100
Friday, April 4, 2008

Upload: others

Post on 04-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Friday, April 4, 2008

Page 2: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchDBJohan Sørensen

Friday, April 4, 2008

Page 3: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

This is CouchDBA wonderful idea

Friday, April 4, 2008

Page 4: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

This is CouchDBA wonderful idea… Based on an awful thing

Friday, April 4, 2008

Page 5: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

This is CouchDBLotus Notes

Friday, April 4, 2008

Page 6: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

This is CouchDBDamien Katz wanted to recreate Lotus Notes

Friday, April 4, 2008

Page 7: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

This is CouchDBDamien Katz wanted to recreate Lotus Notes– But with good API

Friday, April 4, 2008

Page 8: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

This is CouchDBDamien Katz wanted to recreate Lotus Notes– But with good API– A good data format

Friday, April 4, 2008

Page 9: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

This is CouchDBDamien Katz wanted to recreate Lotus Notes– But with good API– A good data format– Open source

Friday, April 4, 2008

Page 10: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

This is CouchDBDamien Katz wanted to recreate Lotus Notes– But with good API– A good data format– Open source– Without wasting effort on making it a silly groupware/email/calendaring application

Friday, April 4, 2008

Page 11: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

This is CouchDB– Apache licensed– Currently under Apache Incubation– Self-funded for two years by Damien Katz– Now sponsored by IBM

Friday, April 4, 2008

Page 12: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

A document database

Friday, April 4, 2008

Page 13: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

With a RESTful API

Friday, April 4, 2008

Page 14: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

With a RESTful APIGET, POST, PUT & DELETE

Friday, April 4, 2008

Page 15: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

With a RESTful APIGET, POST, PUT & DELETE

– Allows us to use existing infrastructure

Friday, April 4, 2008

Page 16: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

With a RESTful APIGET, POST, PUT & DELETE

– Allows us to use existing infrastructureLoad balencers

Friday, April 4, 2008

Page 17: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

With a RESTful APIGET, POST, PUT & DELETE

– Allows us to use existing infrastructureLoad balencers, proxies etc

Friday, April 4, 2008

Page 18: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

With versioning

Friday, April 4, 2008

Page 19: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

With replication

Friday, April 4, 2008

Page 20: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

In a sensible format

Friday, April 4, 2008

Page 21: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

In a sensible format(That means “not XML”)

Friday, April 4, 2008

Page 22: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

In a sensible formatJSON

Friday, April 4, 2008

Page 23: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

In a sensible formatJSON– Human readable

Friday, April 4, 2008

Page 24: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

In a sensible formatJSON– Human readable– Machine readable

Friday, April 4, 2008

Page 25: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

In a sensible formatJSON– Human readable– Machine readable

{ “foo”: “bar” }

Friday, April 4, 2008

Page 26: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

With querying

Friday, April 4, 2008

Page 27: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

With queryingIn Javascript

Friday, April 4, 2008

Page 28: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

With queryingIn Javascript

if (doc.title == “couchdb”)

{ “title”: “couchdb” }

Friday, April 4, 2008

Page 29: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Document oriented applications

Friday, April 4, 2008

Page 30: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Document oriented applicationsIn real life:– A document is a piece of paper

Friday, April 4, 2008

Page 31: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Document oriented applicationsIn real life:– A document is a piece of paper– With “stuff” on it

Friday, April 4, 2008

Page 32: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Document oriented applicationsIn real life:– A document is a piece of paper– With “stuff” on it– Everyone can read and understand “stuff”

Friday, April 4, 2008

Page 33: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Who deals with “stuff”?

Friday, April 4, 2008

Page 34: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Most applications

Friday, April 4, 2008

Page 35: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email

Friday, April 4, 2008

Page 36: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email, notes

Friday, April 4, 2008

Page 37: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email, notes, todos

Friday, April 4, 2008

Page 38: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email, notes, todos, wikis

Friday, April 4, 2008

Page 39: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email, notes, todos, wikis, forums

Friday, April 4, 2008

Page 40: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email, notes, todos, wikis, forums, blogs

Friday, April 4, 2008

Page 41: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email, notes, todos, wikis, forums, blogs, bug reports

Friday, April 4, 2008

Page 42: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email, notes, todos, wikis, forums, blogs, bug reports, CRM

Friday, April 4, 2008

Page 43: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email, notes, todos, wikis, forums, blogs, bug reports, CRM, CMS, expense tracking

Friday, April 4, 2008

Page 44: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email, notes, todos, wikis, forums, blogs, bug reports, CRM, CMS, expense tracking, project management

Friday, April 4, 2008

Page 45: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email, notes, todos, wikis, forums, blogs, bug reports, CRM, CMS, expense tracking, project management, asset tracking

Friday, April 4, 2008

Page 46: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email, notes, todos, wikis, forums, blogs, bug reports, CRM, CMS, expense tracking, project management, asset tracking, TPS reports

Friday, April 4, 2008

Page 47: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email, notes, todos, wikis, forums, blogs, bug reports, CRM, CMS, expense tracking, project management, asset tracking, TPS reports, TPS report coversheets

Friday, April 4, 2008

Page 48: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Email, notes, todos, wikis, forums, blogs, bug reports, CRM, CMS, expense tracking, project management, asset tracking, TPS reports, TPS report coversheets

Friday, April 4, 2008

Page 49: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Most applications!

Friday, April 4, 2008

Page 50: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

A CouchDB Document

Friday, April 4, 2008

Page 51: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

A CouchDB Document{ “_id”: “4B46AFFF0233871EAFC9EA5680E4C90B”, “_rev”: 1778502017, “title”: “My blog post”, “body”: “so last night...”}

Friday, April 4, 2008

Page 52: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Every document– Has a _rev attribute

Friday, April 4, 2008

Page 53: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Every document– Has a _rev attribute– And an _id attribute

Friday, April 4, 2008

Page 54: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Every document– Has a _rev attribute– And an _id attribute (GUUID, or custom)

Friday, April 4, 2008

Page 55: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Every document– Has a _rev attribute– And an _id attribute (GUUID, or custom)– n number of arbitrary key+value JSON data

Friday, April 4, 2008

Page 56: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Creating a document

{ “title”: “My blog post”, “body”: “so last night...”}

POST http://localhost:5984/blog-posts

Friday, April 4, 2008

Page 57: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Creating a document

{ “title”: “My blog post”, “body”: “so last night...”}

POST http://localhost:5984/blog-posts

201 Created

Friday, April 4, 2008

Page 58: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Creating a document with a custom ID

{ “title”: “My blog post”, “body”: “so last night...”}

PUT http://localhost:5984/blog-posts/mycustomid

Friday, April 4, 2008

Page 59: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Updating a document

{ “_rev”: 1778502017, “title”: “My updated blog post”, “body”: “so last night, and it was like you know...”}

PUT http://localhost:5984/blog-posts/mycustomid

Friday, April 4, 2008

Page 60: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

GET a documentGET http://localhost:5984/blog-posts/docid

Friday, April 4, 2008

Page 61: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

GET a specific revisionGET http://localhost:5984/blog-posts/docid?rev=9467819C

Friday, April 4, 2008

Page 62: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

GET all revisionsGET http://localhost:5984/blog-posts/docid?revs=true

Friday, April 4, 2008

Page 63: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Attachments{ _id:“attachment_doc”, _attachments: { “foo.txt”: { “type”:“base64”, “data”: “VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ=” } }}

Friday, April 4, 2008

Page 64: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

AttachmentsGET /database/attachment_doc

{“_id”:“attachment_doc”, “_rev”:1589456116, “_attachments”: { “foo.txt”: { “stub”:true, “type”:“base64”, “length”:29 }}}

GET /database/attachment_doc/foo.txt

Friday, April 4, 2008

Page 65: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Attachments… Still has a fluctuating API

Friday, April 4, 2008

Page 66: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Javascript views

Friday, April 4, 2008

Page 67: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Javascript viewsEssentially “stored procedures” in javascript

Friday, April 4, 2008

Page 68: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Javascript viewsEssentially “stored procedures” in javascript

– Give me all docs with a “title” attribute of “bacon”

Friday, April 4, 2008

Page 69: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Javascript viewsEssentially “stored procedures” in javascript

– Give me all docs with a “title” attribute of “bacon” – Give me all docs where the “title” atribute matches /(chunky|crispy)bacon.+/

Friday, April 4, 2008

Page 70: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Javascript viewsAn anonymous function, that map()’s the results

function(doc) { if (doc.foo == “baz”) { map(null, doc); }}

Friday, April 4, 2008

Page 71: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Javascript viewsA temporary, on-the-fly, view

function(doc) { if (doc.foo == “baz”) { map(null, doc); }}

POST /mydatabase/_temp_view

Friday, April 4, 2008

Page 72: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Javascript viewsPersistant views{ “_id”:“_design/company”, “_rev”:“12345”, “language”: “text/javascript”, “views”: { “all”: “function(doc) { if (doc.Type == ‘customer’) map(null, doc) }” “by_lastname”: “function(doc) { if (doc.Type == ‘customer’) map(doc.LastName, doc) }” }}

Friday, April 4, 2008

Page 73: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Javascript viewsPersistant views

GET /somedatabase/_view/company/all

Friday, April 4, 2008

Page 74: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Javascript viewsPersistant views

Updates a view index everytime a document is created or updated

Friday, April 4, 2008

Page 75: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Bonus features

Friday, April 4, 2008

Page 76: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Bonus features– Fulltext indexing + search

Friday, April 4, 2008

Page 77: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Bonus features– Fulltext indexing + search– Lucene

Friday, April 4, 2008

Page 78: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Bonus features– Fulltext indexing + search– Lucene

WIP:– Sphinx

Friday, April 4, 2008

Page 79: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Bonus features– Fulltext indexing + search– Lucene

WIP:– Sphinx– Xapian (by me - http://gitorious.org/projects/couchdb-xapian)

Friday, April 4, 2008

Page 80: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchDB & Ruby

Friday, April 4, 2008

Page 81: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchDB & Ruby– Net::HTTP + JSON gem

Friday, April 4, 2008

Page 82: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchDB & Ruby– Net::HTTP + JSON gem– CouchObject (gitorious.org/projects/couchobject)

Friday, April 4, 2008

Page 83: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchObject>> db = CouchObject::Database.open(“http://localhost:5984/test“)# => #<CouchObject::Database:0x116b09c @server=#<CouchObject::Server:0x116b038 ...>>> response = db.get(“someid”)# => #<CouchObject::Response:0x1167820 @response=#<Net::HTTPOK 200 OK readbody=true>, ...>>> doc = response.to_document# <CouchObject::Document:0x1165700# @attributes={“title”=>”a document”, “description”=>”it’s schema-free”},# @id=”someid”,# @revision=”2501615157”># >> doc.id# => “someid”>> doc.title# => “a document”>> doc.title = “a new title”# => “a new title”>> doc.save(db)

Friday, April 4, 2008

Page 84: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchObject::Persistable

Friday, April 4, 2008

Page 85: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchObject::Persistableclass Bike include CouchObject::Persistable def initialize @wheels = 2 end attr_accessor :wheels def to_couch {:wheels => @wheels} end def self.from_couch(attributes) bike = new bike.wheels = attributes[“wheels”] bike endend

Friday, April 4, 2008

Page 86: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchObject::Persistable– Adds magic methods to objects (#find, #save etc)

Friday, April 4, 2008

Page 87: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchObject::Persistable– Adds magic methods to objects (#get_by_id, #save etc)– Serialization methods optional, if following conventions

Friday, April 4, 2008

Page 88: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchObject::Persistable– Adds magic methods to objects (#get_by_id, #save etc)– Serialization methods optional, if following conventions– Automagic timestamping

Friday, April 4, 2008

Page 89: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchObject::Persistable– Adds magic methods to objects (#get_by_id, #save etc)– Serialization methods optional, if following conventions– Automagic timestamping– has_many, has_one & belongs_to style relations

Friday, April 4, 2008

Page 90: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchObject::Persistable– Adds magic methods to objects (#get_by_id, #save etc)– Serialization methods optional, if following conventions– Automagic timestamping– has_many, has_one & belongs_to style relationsWhere the related part is either stored in the same document, or in another document

Friday, April 4, 2008

Page 91: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchObjecthttp://gitorious.org/projects/couchobject

Up-to-date gem Coming Soon™

Friday, April 4, 2008

Page 92: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchDB Future– Live compaction (committed yesterday)

Friday, April 4, 2008

Page 93: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchDB Future– Live compaction (committed yesterday)– Working reduce implementation

Friday, April 4, 2008

Page 94: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Reduce part of map/reduce

tag count

ruby 1

rails 1

ruby 1

java 0

tag reduced

ruby 2

rails 1

java 0

mapped docs reduced

Friday, April 4, 2008

Page 95: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchDB Future– Live compaction (committed today)– Working reduce implementation– Access control

Friday, April 4, 2008

Page 96: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchDB Future– Live compaction (committed today)– Working reduce implementation– Access control– Easier sharding/partioning

Friday, April 4, 2008

Page 97: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

CouchDB demo

Friday, April 4, 2008

Page 98: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Friday, April 4, 2008

Page 99: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Questions?

Johan Sø[email protected]

Friday, April 4, 2008

Page 100: Friday, April 4, 2008jaoo.dk/dl/jaoo-ruby-oslo-2008/slides/CouchDB.pdf · This is CouchDB Damien Katz wanted to recreate Lotus Notes – But with good API – A good data format –

Thank youJohan Sørensen

[email protected]

Friday, April 4, 2008