couchdb: the last restful json store you'll ever need
TRANSCRIPT
![Page 1: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/1.jpg)
CouchDB: the last RESTful JSON service you’ll ever needCarlo Cabanilla
![Page 2: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/2.jpg)
CouchDB is a RESTful JSON store
![Page 3: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/3.jpg)
CouchDB is a RESTful JSON store
![Page 4: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/4.jpg)
Create
![Page 5: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/5.jpg)
> PUT /mydb/stuff> Content-type: application/json>> {"thing_count":1}
Create
![Page 6: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/6.jpg)
> PUT /mydb/stuff> Content-type: application/json>> {"thing_count":1}
< HTTP/1.1 201 Created<< {"_id":"stuff", < "_rev":"1-e86a94c1...", < "thing_count":1}
Create
![Page 7: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/7.jpg)
Read
![Page 8: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/8.jpg)
> GET /mydb/stuff
Read
![Page 9: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/9.jpg)
> GET /mydb/stuff
< HTTP/1.1 200 OK<< {"_id":"stuff", < "_rev":"1-e86a94c1...", < "thing_count":1}
Read
![Page 10: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/10.jpg)
Update
![Page 11: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/11.jpg)
> PUT /mydb/stuff> Content-type: application/json>> {"_id":"stuff", > "_rev":"1-e86a94c1...", > "thing_count":13}
Update
![Page 12: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/12.jpg)
> PUT /mydb/stuff> Content-type: application/json>> {"_id":"stuff", > "_rev":"1-e86a94c1...", > "thing_count":13}
Update
< HTTP/1.1 201 Created<< {"_id":"stuff", < "_rev":"2-39a9bf12...", < "thing_count":13}
![Page 13: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/13.jpg)
Delete
![Page 14: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/14.jpg)
> DELETE /mydb/stuff?rev=2-39a9bf12...
Delete
![Page 15: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/15.jpg)
> DELETE /mydb/stuff?rev=2-39a9bf12...
Delete
< HTTP/1.1 200 OK
![Page 16: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/16.jpg)
a RESTful JSON store
![Page 17: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/17.jpg)
a RESTful JSON store
![Page 18: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/18.jpg)
PUT /look/ma/im/doing/rest
![Page 19: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/19.jpg)
PUT /look/ma/im/doing/rest
Do you support Conditional GET?
![Page 20: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/20.jpg)
Conditional GET is the
holy grail of
REST
![Page 21: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/21.jpg)
Conditional GET is the holy grail of REST
![Page 22: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/22.jpg)
> GET /that/money
Conditional GET is the holy grail of REST
![Page 23: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/23.jpg)
> GET /that/money
< HTTP/1.1 200 OK<< {“that_money”: “$5”}
Conditional GET is the holy grail of REST
![Page 24: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/24.jpg)
Conditional GET is the holy grail of REST
![Page 25: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/25.jpg)
> GET /that/money
Conditional GET is the holy grail of REST
![Page 26: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/26.jpg)
> GET /that/money
(wait for a few ms)
Conditional GET is the holy grail of REST
![Page 27: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/27.jpg)
> GET /that/money
< HTTP/1.1 200 OK<< {“that_money”: “$5”}
(wait for a few ms)
Conditional GET is the holy grail of REST
![Page 28: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/28.jpg)
( )> GET /that/money
< HTTP/1.1 200 OK<< {“that_money”: “$5”}
(wait for a few ms)
x 1,000,000
Conditional GET is the holy grail of REST
![Page 29: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/29.jpg)
( )> GET /that/money
< HTTP/1.1 200 OK<< {“that_money”: “$5”}
(wait for a few ms)
x 1,000,000 = slow!
Conditional GET is the holy grail of REST
![Page 30: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/30.jpg)
Conditional GET is the holy grail of REST
![Page 31: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/31.jpg)
> GET /that/money
Conditional GET is the holy grail of REST
![Page 32: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/32.jpg)
> GET /that/money
(Uncached: slow)
Conditional GET is the holy grail of REST
![Page 33: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/33.jpg)
> GET /that/money
< HTTP/1.1 200 OK< Etag: "1-24c87859"<< {“that_money”: “$5”}
(Uncached: slow)
Conditional GET is the holy grail of REST
![Page 34: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/34.jpg)
> GET /that/money
< HTTP/1.1 200 OK< Etag: "1-24c87859"<< {“that_money”: “$5”}
(Uncached: slow)
Conditional GET is the holy grail of REST
![Page 35: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/35.jpg)
Conditional GET is the holy grail of REST
![Page 36: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/36.jpg)
> GET /that/money> If-None-Match: "1-24c87859"
Conditional GET is the holy grail of REST
![Page 37: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/37.jpg)
> GET /that/money> If-None-Match: "1-24c87859"
Conditional GET is the holy grail of REST
![Page 38: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/38.jpg)
> GET /that/money> If-None-Match: "1-24c87859"
(Cache hit: fast)
Conditional GET is the holy grail of REST
![Page 39: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/39.jpg)
> GET /that/money> If-None-Match: "1-24c87859"
< HTTP/1.1 304 Not Modified< Etag: "1-24c87859"< Content-Length: 0
(Cache hit: fast)
Conditional GET is the holy grail of REST
![Page 40: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/40.jpg)
Conditional GET is the holy grail of REST
![Page 41: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/41.jpg)
> GET /that/money> If-None-Match: "1-24c87859"
Conditional GET is the holy grail of REST
![Page 42: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/42.jpg)
> GET /that/money> If-None-Match: "1-24c87859"
(Data changed so cache miss )
Conditional GET is the holy grail of REST
![Page 43: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/43.jpg)
> GET /that/money> If-None-Match: "1-24c87859"
< HTTP/1.1 200 Ok< Etag: "2-535d9fb2"< < {“that_money”: “$1,000,000”}
(Data changed so cache miss )
Conditional GET is the holy grail of REST
![Page 44: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/44.jpg)
a RESTful JSON store
![Page 45: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/45.jpg)
a RESTful JSON store
![Page 46: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/46.jpg)
![Page 47: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/47.jpg)
GET /my_db/some_id
![Page 48: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/48.jpg)
GET /my_db/some_id
{
![Page 49: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/49.jpg)
GET /my_db/some_id
{ "_id": "some_id",
![Page 50: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/50.jpg)
GET /my_db/some_id
{ "_id": "some_id", "_rev": "1-24c8785964763c21d...",
![Page 51: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/51.jpg)
GET /my_db/some_id
{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings",
![Page 52: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/52.jpg)
GET /my_db/some_id
{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings", "numbers too": 123.12,
![Page 53: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/53.jpg)
GET /my_db/some_id
{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings", "numbers too": 123.12, "and arrays": ["ain't", "it", "cool?"],
![Page 54: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/54.jpg)
GET /my_db/some_id
{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings", "numbers too": 123.12, "and arrays": ["ain't", "it", "cool?"], "dicts too!": { "don't":"try",
![Page 55: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/55.jpg)
GET /my_db/some_id
{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings", "numbers too": 123.12, "and arrays": ["ain't", "it", "cool?"], "dicts too!": { "don't":"try", "this":"in",
![Page 56: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/56.jpg)
GET /my_db/some_id
{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings", "numbers too": 123.12, "and arrays": ["ain't", "it", "cool?"], "dicts too!": { "don't":"try", "this":"in", "Oracle!":null }
![Page 57: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/57.jpg)
GET /my_db/some_id
{ "_id": "some_id", "_rev": "1-24c8785964763c21d...", "my_field1": "json does strings", "numbers too": 123.12, "and arrays": ["ain't", "it", "cool?"], "dicts too!": { "don't":"try", "this":"in", "Oracle!":null }}
![Page 58: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/58.jpg)
Schema-less
![Page 59: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/59.jpg)
How do I know what a document means??
![Page 60: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/60.jpg)
Duck-type your database
![Page 61: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/61.jpg)
Duck-type your database
Duck-typing
![Page 62: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/62.jpg)
def document_factory(doc):
Duck-type your database
Duck-typing
![Page 63: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/63.jpg)
def document_factory(doc): if doc['look'] == Duck.look()
Duck-type your database
Duck-typing
![Page 64: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/64.jpg)
def document_factory(doc): if doc['look'] == Duck.look() and doc['swim'] == Duck.swim()
Duck-type your database
Duck-typing
![Page 65: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/65.jpg)
def document_factory(doc): if doc['look'] == Duck.look() and doc['swim'] == Duck.swim() and doc['quack'] == Duck.quack():
Duck-type your database
Duck-typing
![Page 66: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/66.jpg)
def document_factory(doc): if doc['look'] == Duck.look() and doc['swim'] == Duck.swim() and doc['quack'] == Duck.quack(): return Duck(doc)
Duck-type your database
Duck-typing
![Page 67: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/67.jpg)
Duck-type your database
Python
![Page 68: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/68.jpg)
def document_factory(doc):
Duck-type your database
Python
![Page 69: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/69.jpg)
def document_factory(doc): if doc['type'] == 'Duck':
Duck-type your database
Python
![Page 70: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/70.jpg)
def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc)
Duck-type your database
Python
![Page 71: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/71.jpg)
def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc) elif doc['type'] == 'Dog':
Duck-type your database
Python
![Page 72: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/72.jpg)
def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc) elif doc['type'] == 'Dog': return Dog(doc)
Duck-type your database
Python
![Page 73: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/73.jpg)
def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc) elif doc['type'] == 'Dog': return Dog(doc) elif ...:
Duck-type your database
Python
![Page 74: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/74.jpg)
def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc) elif doc['type'] == 'Dog': return Dog(doc) elif ...: ...
Duck-type your database
Python
![Page 75: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/75.jpg)
def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc) elif doc['type'] == 'Dog': return Dog(doc) elif ...: ... else:
Duck-type your database
Python
![Page 76: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/76.jpg)
def document_factory(doc): if doc['type'] == 'Duck': return Duck(doc) elif doc['type'] == 'Dog': return Dog(doc) elif ...: ... else: return GenericDocument(doc)
Duck-type your database
Python
![Page 77: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/77.jpg)
Duck-type your database
Python
![Page 78: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/78.jpg)
def document_factory(doc):
Duck-type your database
Python
![Page 79: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/79.jpg)
def document_factory(doc): import document_types
Duck-type your database
Python
![Page 80: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/80.jpg)
def document_factory(doc): import document_types doc_class = getattr(doc, doc['type'],
Duck-type your database
Python
![Page 81: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/81.jpg)
def document_factory(doc): import document_types doc_class = getattr(doc, doc['type'], 'GenericDocument')
Duck-type your database
Python
![Page 82: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/82.jpg)
def document_factory(doc): import document_types doc_class = getattr(doc, doc['type'], 'GenericDocument') return doc_class(doc)
Duck-type your database
Python
![Page 83: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/83.jpg)
Duck-type your database
Java
![Page 84: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/84.jpg)
public static CouchObj documentFactory(CouchDoc doc) {
Duck-type your database
Java
![Page 85: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/85.jpg)
public static CouchObj documentFactory(CouchDoc doc) { ClassLoader loader = CouchObj.class.getClassLoader();
Duck-type your database
Java
![Page 86: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/86.jpg)
public static CouchObj documentFactory(CouchDoc doc) { ClassLoader loader = CouchObj.class.getClassLoader(); dispatcherClass = loader.loadClass(doc.get("type"));
Duck-type your database
Java
![Page 87: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/87.jpg)
public static CouchObj documentFactory(CouchDoc doc) { ClassLoader loader = CouchObj.class.getClassLoader(); dispatcherClass = loader.loadClass(doc.get("type")); return (CouchObj) dispatcherClass.newInstance(doc);
Duck-type your database
Java
![Page 88: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/88.jpg)
public static CouchObj documentFactory(CouchDoc doc) { ClassLoader loader = CouchObj.class.getClassLoader(); dispatcherClass = loader.loadClass(doc.get("type")); return (CouchObj) dispatcherClass.newInstance(doc);}
Duck-type your database
Java
![Page 89: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/89.jpg)
That’s silly. How do I query something that has no schema?
![Page 90: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/90.jpg)
That’s silly. How do I query something that has no schema?
![Page 91: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/91.jpg)
You write a map reduce function in Javascript!
What the heck is map reduce (in CouchDB)?
![Page 92: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/92.jpg)
You write a map reduce function in Javascript!
What the heck is map reduce (in CouchDB)?
map reduce ≈ programmatically building an index
![Page 93: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/93.jpg)
You write a map reduce function in Javascript!
![Page 94: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/94.jpg)
You write a map reduce function in Javascript!
In CouchDB, a map/reduce pair is called a view.
![Page 95: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/95.jpg)
You write a map reduce function in Javascript!
In CouchDB, a map/reduce pair is called a view.(different from a RDBMS view!)
![Page 96: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/96.jpg)
You write a map reduce function in Javascript!
In CouchDB, a map/reduce pair is called a view.(different from a RDBMS view!)
On creation => full database scan then cacheOn db write => incrementally update the cache
![Page 97: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/97.jpg)
You write a map reduce function in Javascript!
In CouchDB, a map/reduce pair is called a view.(different from a RDBMS view!)
On creation => full database scan then cacheOn db write => incrementally update the cache
(different from Hadoop map reduce!)
![Page 98: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/98.jpg)
You write a map reduce function in Javascript!
![Page 99: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/99.jpg)
You write a map reduce function in Javascript!
You can tell CouchDB to store any data in the view
![Page 100: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/100.jpg)
You write a map reduce function in Javascript!
You can tell CouchDB to store any data in the view(RDBMSs only store indexed values and row ids)
![Page 101: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/101.jpg)
You write a map reduce function in Javascript!
You can tell CouchDB to store any data in the view(RDBMSs only store indexed values and row ids)
CouchDB view ≈ RDBMS index + materialized view
![Page 102: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/102.jpg)
You write a map reduce function in Javascript!
Yo, data structures nerds,
![Page 103: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/103.jpg)
You write a map reduce function in Javascript!
Yo, data structures nerds,
a CouchDB view is a B+ tree
![Page 104: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/104.jpg)
You write a map reduce function in Javascript!
Yo, data structures nerds,
a CouchDB view is a B+ treemap function determines how keys map to values
![Page 105: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/105.jpg)
You write a map reduce function in Javascript!
Yo, data structures nerds,
a CouchDB view is a B+ treemap function determines how keys map to values
keys are stored in sorted order
![Page 106: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/106.jpg)
You write a map reduce function in Javascript!
Yo, data structures nerds,
a CouchDB view is a B+ treemap function determines how keys map to values
keys are stored in sorted order
O(log n) for reads, writes, deletes and range queries
![Page 107: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/107.jpg)
You write a map reduce function in Javascript!
Yo, data structures nerds,
a CouchDB view is a B+ treemap function determines how keys map to values
keys are stored in sorted order
O(log n) for reads, writes, deletes and range queries
keys are stored close to values
![Page 108: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/108.jpg)
You write a map reduce function in Javascript!
![Page 109: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/109.jpg)
You write a map reduce function in Javascript!
For example:
Create an view called people on the names of all person documents.
![Page 110: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/110.jpg)
You write a map reduce function in Javascript!
function map(doc) { if (doc['type'] == 'person') { emit(doc['name'], doc); }}
For example:
Create an view called people on the names of all person documents.
![Page 111: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/111.jpg)
You write a map reduce function in Javascript!
function map(doc) { if (doc['type'] == 'person') { emit(doc['name'], doc); }}
function reduce(keys, values) { return values.length; }
For example:
Create an view called people on the names of all person documents.
![Page 112: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/112.jpg)
You write a map reduce function in Javascript!
![Page 113: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/113.jpg)
You write a map reduce function in Javascript!
SELECT count(*) FROM people
![Page 114: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/114.jpg)
You write a map reduce function in Javascript!
SELECT count(*) FROM people
GET /people
![Page 115: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/115.jpg)
You write a map reduce function in Javascript!
SELECT name, count(*) FROM people GROUP BY name ORDER BY name ASC
SELECT count(*) FROM people
GET /people
![Page 116: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/116.jpg)
You write a map reduce function in Javascript!
SELECT name, count(*) FROM people GROUP BY name ORDER BY name ASC
GET /people?group=true
SELECT count(*) FROM people
GET /people
![Page 117: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/117.jpg)
You write a map reduce function in Javascript!
SELECT name, count(*) FROM people GROUP BY name ORDER BY name ASC
GET /people?group=true
SELECT count(*) FROM people
GET /people
SELECT * FROM people ORDER BY name ASC
![Page 118: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/118.jpg)
You write a map reduce function in Javascript!
SELECT name, count(*) FROM people GROUP BY name ORDER BY name ASC
GET /people?group=true
SELECT count(*) FROM people
GET /people
SELECT * FROM people ORDER BY name ASC
GET /people?reduce=false
![Page 119: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/119.jpg)
You write a map reduce function in Javascript!
![Page 120: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/120.jpg)
You write a map reduce function in Javascript!
SELECT * FROM people WHERE name = “bjorn”
![Page 121: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/121.jpg)
You write a map reduce function in Javascript!
SELECT * FROM people WHERE name = “bjorn”
GET /people?reduce=false&key=”bjorn”
![Page 122: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/122.jpg)
You write a map reduce function in Javascript!
SELECT * FROM people WHERE name = “bjorn”
GET /people?reduce=false&key=”bjorn”
SELECT * FROM ( SELECT p.*, rownum rn FROM people p ORDER BY name ASC) WHERE rn BETWEEN 50 AND 60
![Page 123: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/123.jpg)
You write a map reduce function in Javascript!
SELECT * FROM people WHERE name = “bjorn”
GET /people?reduce=false&key=”bjorn”
SELECT * FROM ( SELECT p.*, rownum rn FROM people p ORDER BY name ASC) WHERE rn BETWEEN 50 AND 60
GET /people?reduce=false&limit=10&skip=50
![Page 124: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/124.jpg)
You write a map reduce function in Javascript!
What about joins??????
![Page 125: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/125.jpg)
You write a map reduce function in Javascript!
![Page 126: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/126.jpg)
You write a map reduce function in Javascript!
j/k.
Joins will be in version 0.11 (trunk)
![Page 127: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/127.jpg)
You write a map reduce function in Javascript!
j/k.
Joins will be in version 0.11 (trunk)
function map(doc) { for (i in doc['comment_ids']) { var comment_id = doc['comment_ids'][i]; emit(doc['_id'], {'_id': comment_id }); }}
![Page 128: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/128.jpg)
You write a map reduce function in Javascript!
[ {'_id': 1, 'comment_ids': [3, 4]}, {'_id': 2, 'comment_ids': [5]}, {'_id': 3, 'text': 'whoa'}, {'_id': 4, 'text': 'omg'}, {'_id': 5, 'text': 'ponies'}]
Documents in my blog db
![Page 129: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/129.jpg)
You write a map reduce function in Javascript!
[ {'_id': 1, 'comment_ids': [3, 4]}, {'_id': 2, 'comment_ids': [5]}, {'_id': 3, 'text': 'whoa'}, {'_id': 4, 'text': 'omg'}, {'_id': 5, 'text': 'ponies'}]
Documents in my blog db
GET /myblog/comments? reduce=false&include_docs=true
![Page 130: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/130.jpg)
You write a map reduce function in Javascript!
[ {'_id': 1, 'comment_ids': [3, 4]}, {'_id': 2, 'comment_ids': [5]}, {'_id': 3, 'text': 'whoa'}, {'_id': 4, 'text': 'omg'}, {'_id': 5, 'text': 'ponies'}]
Documents in my blog db
GET /myblog/comments? reduce=false&include_docs=true
[ {'key': 1, 'value': {'_id': 3, 'text': 'whoa'}}, {'key': 1, 'value': {'_id': 4, 'text': 'omg'}}, {'key': 5, 'value': {'_id': 5, 'text': 'ponies'}}]
![Page 131: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/131.jpg)
Ok great, so it can pretty much do what a RDBMS can do.
![Page 132: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/132.jpg)
Ok great, so it can pretty much do what a RDBMS can do.
Why not just use a RDBMS?
![Page 133: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/133.jpg)
The real question you should be asking yourself is:
![Page 134: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/134.jpg)
Why keep rewriting HTTP protocol semantics and data object accessorsto front your RDBMS?
The real question you should be asking yourself is:
![Page 135: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/135.jpg)
![Page 136: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/136.jpg)
![Page 137: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/137.jpg)
Middle tier-less web apps!(well, kind of)
![Page 138: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/138.jpg)
No, forreals,
![Page 139: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/139.jpg)
No, forreals,
Why not just use a RDBMS?
![Page 140: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/140.jpg)
ORACLE
![Page 141: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/141.jpg)
OMGReallyAsininelyCostlyLicencingExpenses
ORACLE
![Page 142: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/142.jpg)
ClusterOf Unreliable Commodity Hardware DataBase
![Page 143: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/143.jpg)
ClusterOf Unreliable Commodity Hardware DataBase
?
![Page 144: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/144.jpg)
Cluster?
Replication!
![Page 145: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/145.jpg)
Cluster?
Replication!
Incremental,
![Page 146: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/146.jpg)
Cluster?
Replication!
Incremental,Fault Tolerant,
![Page 147: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/147.jpg)
Cluster?
Replication!
Incremental,Fault Tolerant,Over HTTP
![Page 148: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/148.jpg)
replication is expensive
![Page 149: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/149.jpg)
Mmm, yeah how much did we pay for the LSB?
replication is expensive
![Page 150: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/150.jpg)
Mmm, yeah how much did we pay for the LSB?
replication is expensive
Seems to work well tho(fingers crossed)
![Page 151: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/151.jpg)
Postgres replication is . . . ?
![Page 152: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/152.jpg)
No native replication support yet (coming in v9.0)
Postgres replication is . . . ?
![Page 153: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/153.jpg)
No native replication support yet (coming in v9.0)
Postgres replication is . . . ?
3rd party solutions are trigger-based (yuck)
![Page 154: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/154.jpg)
Replication!
Managing replication conflicts (abends)
![Page 155: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/155.jpg)
Replication!
Managing replication conflicts (abends)
Deterministically pick a version to “win”
![Page 156: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/156.jpg)
Replication!
Managing replication conflicts (abends)
Deterministically pick a version to “win”
Add a “\_conflict” property to the document
![Page 157: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/157.jpg)
Replication!
Managing replication conflicts (abends)
Deterministically pick a version to “win”
Add a “\_conflict” property to the document
App must resolve the conflict
![Page 158: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/158.jpg)
Replication!
Managing replication conflicts (abends)
Much better explanation here:http://books.couchdb.org/relax/reference/conflict-management
Deterministically pick a version to “win”
Add a “\_conflict” property to the document
App must resolve the conflict
![Page 159: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/159.jpg)
Let’s see some appz!
![Page 160: CouchDB: the last RESTful JSON store you'll ever need](https://reader034.vdocuments.site/reader034/viewer/2022051013/546b26aab4af9f892c8b4aa2/html5/thumbnails/160.jpg)
• Design philosophy
• Transforming views with list functions
• Lucene integration
• Performance benchmarks
• Erlang under the hood
• Many to many relationships
• Changes feed
• Potential applications at WGen
• Elaborate on middle tier-less web apps
Not enough time :(