CouchDB Day NYC 2017: Introduction to CouchDB 2.0

149
Apache CouchDB Developer Day Bradley Holt, Developer Advocate Thursday, February 9, 2017 Introducing Apache CouchDB 2.0 @BradleyHolt

Transcript of CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Page 1: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Apache CouchDB Developer Day

Bradley Holt, Developer AdvocateThursday, February 9, 2017

Introducing Apache CouchDB 2.0

@BradleyHolt

Page 2: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

@BradleyHolt

Page 3: CouchDB Day NYC 2017: Introduction to CouchDB 2.0
Page 4: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

IBM Cloud Data Services

Open for DataA comprehensive portfolio of open source data services

Page 5: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

What is Apache CouchDB?

Page 6: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Document DatabaseApache CouchDB is a JSON document database

Page 7: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

HTTP APIApache CouchDB is accessed through an HTTP API

@BradleyHolt

GET /

GET /db/docPOST /db

DELETE /db/docPUT /db/doc

PUT /db

Page 8: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Peer-to-Peer Replication

@BradleyHolt

Cloudant SyncCouchDB PouchDB

CouchDB Replication Protocol

CouchDB

Page 9: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

What's new in CouchDB 2.0?

Page 10: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

CouchDB 1.x: Standalone

@BradleyHolt

CouchDB

Page 11: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

CouchDB 2.0: Clusterered

@BradleyHolt

CouchDBnode1

CouchDBnode2

CouchDBnode3

haproxy

Page 12: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Shards and Replicas

q=8– Number of shards– One or more shards per node– Cannot have more nodes than shards

r=2– Read quorum

w=2– Write quorum

n=3– Number of replicas of every document

@BradleyHolt

CouchDBnode1

CouchDBnode2

CouchDBnode3

Page 13: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

Declarative indexes MongoDB-style query language You can still use map/reduce views

@BradleyHolt

Page 14: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

couch_peruser

@BradleyHolt

userdb-51d055

userdb-d76846userdb-905cec

userdb-adc95b

userdb-c082f2

userdb-730bba

userdb-c3d3e5

userdb-da3d25

userdb-a1ec1f

userdb-85bcfe

userdb-85a327userdb-9b9aba

Page 15: CouchDB Day NYC 2017: Introduction to CouchDB 2.0
Page 16: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

What else is new?

Improved database compaction Faster index updates New _bulk_get endpoint for

optimized replication View-based filters in _changes feed Filter _changes feed with _doc_ids _all_docs and _changes will

support attachments=true

@BradleyHolt

Page 17: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Installing CouchDB 2.0

Page 18: CouchDB Day NYC 2017: Introduction to CouchDB 2.0
Page 19: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Apache CouchDB 2.0 Sandbox ClusterTry Apache CouchDB 2.0 on an IBM Cloudant sandbox cluster

@BradleyHolt

Page 20: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

http-console

Page 22: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

http-console

$ npm install http-console -g$ http-console 127.0.0.1:5984

@BradleyHolthttps://github.com/cloudhead/http-console

Page 23: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

http-console

$ npm install http-console -g$ http-console 127.0.0.1:5984> http-console 0.6.3> Welcome, enter .help if you're lost.> Connecting to 127.0.0.1 on port 5984.

@BradleyHolthttps://github.com/cloudhead/http-console

Page 26: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

http-console

http://127.0.0.1:5984/> GET /HTTP/1.1 200 OKContent-Type: text/plain; charset=utf-8

{ couchdb: 'Welcome', version: '9afa6a0', vendor: { name: 'The Apache Software Foundation' }}

@BradleyHolthttps://github.com/cloudhead/http-console

Page 30: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

http-console

$ http-console https://bradley-holt.cloudant.com> http-console 0.6.3> Welcome, enter .help if you're lost.> Connecting to bradley-holt.cloudant.com on port 443.

@BradleyHolthttps://github.com/cloudhead/http-console

Page 33: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

http-console

https://bradley-holt.cloudant.com:443/> GET /HTTP/1.1 200 OKContent-Type: application/json

{ couchdb: 'Welcome', version: '9d28c57', vendor: { name: 'IBM Cloudant', version: '5331', variant: 'paas' }, features: [ 'geo' ]}

@BradleyHolthttps://github.com/cloudhead/http-console

Page 36: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Exploring the CouchDB API

Page 37: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Connecting to CouchDB 2.0

$ http-console root:[email protected]:5984 --json

@BradleyHolt

Page 38: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Connecting to CouchDB 2.0

$ http-console root:[email protected]:5984 --json> http-console 0.6.3> Welcome, enter .help if you're lost.> Connecting to 127.0.0.1 on port 5984.

@BradleyHolt

Page 39: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Connecting to IBM Cloudant

$ http-console https://bradley-holt:[email protected] --json

@BradleyHolt

Page 40: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Connecting to IBM Cloudant

$ http-console https://bradley-holt:[email protected] --json> http-console 0.6.3> Welcome, enter .help if you're lost.> Connecting to bradley-holt.cloudant.com on port 443.

@BradleyHolt

Page 41: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Request Headers

/>

@BradleyHolt

Page 42: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Request Headers

/> .headers

@BradleyHolt

Page 43: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Request Headers

/> .headersAccept: application/jsonContent-Type: application/jsonAuthorization: Basic cm9vdDorMi95N3Y2aA==Host: 127.0.0.1

@BradleyHolt

Page 44: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT a Database

/>

@BradleyHolt

Page 45: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT a Database

/> PUT /kittens

@BradleyHolt

Page 46: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT a Database

/> PUT /kittens...

@BradleyHolt

Page 47: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT a Database

/> PUT /kittens... HTTP/1.1 201 CreatedContent-Type: application/jsonLocation: http://127.0.0.1/kittens

{ ok: true }

@BradleyHolt

Page 48: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT a Database Again

/>

@BradleyHolt

Page 49: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT a Database Again

/> PUT /kittens

@BradleyHolt

Page 50: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT a Database Again

/> PUT /kittens...

@BradleyHolt

Page 51: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT a Database Again

/> PUT /kittens... HTTP/1.1 412 Precondition FailedContent-Type: application/json

{ error: 'file_exists', reason: 'The database could not be created, the file already exists.' }

@BradleyHolt

Page 52: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

POST a Document

/>

@BradleyHolt

Page 53: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

POST a Document

/> /kittens

@BradleyHolt

Page 54: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

POST a Document

/kittens>

@BradleyHolt

Page 55: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

POST a Document

/kittens> POST /

@BradleyHolt

Page 56: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

POST a Document

/kittens> POST /...

@BradleyHolt

Page 57: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

POST a Document

/kittens> POST /... { "_id": "mittens", "age_weeks": 10, "weight_kilograms": 0.997 }

@BradleyHolt

Page 58: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

POST a Document

/kittens> POST /... { "_id": "mittens", "age_weeks": 10, "weight_kilograms": 0.997 }HTTP/1.1 201 CreatedContent-Type: application/jsonLocation: http://127.0.0.1/kittens/mittens

{ ok: true, id: 'mittens', rev: '1-e665a40d9ea9711c983e907f0b0b6e8a'}

@BradleyHolt

Page 59: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

GET All Documents

/kittens>

@BradleyHolt

Page 60: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

GET All Documents

/kittens> GET /_all_docs

@BradleyHolt

Page 61: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

GET All Documents

/kittens> GET /_all_docsHTTP/1.1 200 OKContent-Type: application/jsonEtag: "92afa0f309a9fd9f140cd31ff5000b5c"

{ total_rows: 1, offset: 0, rows: [ { id: 'mittens', key: 'mittens', value: { rev: '1-e665a40d9ea9711c983e907f0b0b6e8a' } } ]}

@BradleyHolt

Page 62: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

GET a Document

/kittens>

@BradleyHolt

Page 63: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

GET a Document

/kittens> GET /mittens

@BradleyHolt

Page 64: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

GET a Document

/kittens> GET /mittensHTTP/1.1 200 OKContent-Type: application/jsonEtag: "1-e665a40d9ea9711c983e907f0b0b6e8a"

{ _id: 'mittens', _rev: '1-e665a40d9ea9711c983e907f0b0b6e8a', age_weeks: 10, weight_kilograms: 0.997}

@BradleyHolt

Page 65: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT an Attachment

/kittens>

@BradleyHolt

Page 66: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT an Attachment

/kittens> .headers

@BradleyHolt

Page 67: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT an Attachment

/kittens> .headersAccept: application/jsonContent-Type: application/jsonAuthorization: Basic cm9vdDorMi95N3Y2aA==Host: 127.0.0.1

@BradleyHolt

Page 68: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT an Attachment

/kittens> .headersAccept: application/jsonContent-Type: application/jsonAuthorization: Basic cm9vdDorMi95N3Y2aA==Host: 127.0.0.1/kittens> Content-Type: image/gif

@BradleyHolt

Page 69: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT an Attachment

/kittens>

@BradleyHolt

Page 70: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT an Attachment

/kittens> PUT /mittens/photo?rev=1-e665a40d9ea9711c983e907f0b0b6e8a

@BradleyHolt

Page 71: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT an Attachment

/kittens> PUT /mittens/photo?rev=1-e665a40d9ea9711c983e907f0b0b6e8a...

@BradleyHolt

Page 72: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT an Attachment

/kittens> PUT /mittens/photo?rev=1-e665a40d9ea9711c983e907f0b0b6e8a... R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=

@BradleyHolt

Page 73: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT an Attachment

/kittens> PUT /mittens/photo?rev=1-e665a40d9ea9711c983e907f0b0b6e8a... R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=HTTP/1.1 201 CreatedContent-Type: application/jsonLocation: http://127.0.0.1/kittens/mittens/photo

{ ok: true, id: 'mittens', rev: '2-d858e51453a5785bafe517b7eddc5a98'}

@BradleyHolt

Page 74: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT an Attachment

/kittens> PUT /mittens/photo?rev=1-e665a40d9ea9711c983e907f0b0b6e8a... R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=HTTP/1.1 201 CreatedContent-Type: application/jsonLocation: http://127.0.0.1/kittens/mittens/photo

{ ok: true, id: 'mittens', rev: '2-d858e51453a5785bafe517b7eddc5a98'}/kittens>

@BradleyHolt

Page 75: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

PUT an Attachment

/kittens> PUT /mittens/photo?rev=1-e665a40d9ea9711c983e907f0b0b6e8a... R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=HTTP/1.1 201 CreatedContent-Type: application/jsonLocation: http://127.0.0.1/kittens/mittens/photo

{ ok: true, id: 'mittens', rev: '2-d858e51453a5785bafe517b7eddc5a98'}/kittens> Content-Type: application/json

@BradleyHolt

Page 76: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

GET an Attachment

/kittens>

@BradleyHolt

Page 77: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

GET an Attachment

/kittens> GET /mittens/photo

@BradleyHolt

Page 78: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

GET an Attachment

/kittens> GET /mittens/photoHTTP/1.1 200 OKContent-Type: image/gifEtag: "UsqjdPnY6ApD2ENFOglFHg=="

R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=

@BradleyHolt

Page 79: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Conditional Caching

/kittens>

@BradleyHolt

Page 80: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Conditional Caching

/kittens> If-None-Match: "UsqjdPnY6ApD2ENFOglFHg=="

@BradleyHolt

Page 81: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Conditional Caching

/kittens> If-None-Match: "UsqjdPnY6ApD2ENFOglFHg=="/kittens>

@BradleyHolt

Page 82: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Conditional Caching

/kittens> If-None-Match: "UsqjdPnY6ApD2ENFOglFHg=="/kittens> GET /mittens/photo

@BradleyHolt

Page 83: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Conditional Caching

/kittens> If-None-Match: "UsqjdPnY6ApD2ENFOglFHg=="/kittens> GET /mittens/photoHTTP/1.1 304 Not Modified

@BradleyHolt

Page 84: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Conditional Caching

/kittens> If-None-Match: "UsqjdPnY6ApD2ENFOglFHg=="/kittens> GET /mittens/photoHTTP/1.1 304 Not Modified

/kittens>

@BradleyHolt

Page 85: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Conditional Caching

/kittens> If-None-Match: "UsqjdPnY6ApD2ENFOglFHg=="/kittens> GET /mittens/photoHTTP/1.1 304 Not Modified

/kittens> If-None-Match:

@BradleyHolt

Page 86: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

DELETE a Document

/kittens>

@BradleyHolt

Page 87: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

DELETE a Document

/kittens> DELETE /mittens

@BradleyHolt

Page 88: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

DELETE a Document

/kittens> DELETE /mittensHTTP/1.1 409 ConflictContent-Type: application/json

{ error: 'conflict', reason: 'Document update conflict.' }

@BradleyHolt

Page 89: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

DELETE a Document

/kittens>

@BradleyHolt

Page 90: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

DELETE a Document

/kittens> HEAD /mittens

@BradleyHolt

Page 91: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

DELETE a Document

/kittens> HEAD /mittensHTTP/1.1 200 OKEtag: "2-d858e51453a5785bafe517b7eddc5a98"

@BradleyHolt

Page 92: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

DELETE a Document

/kittens>

@BradleyHolt

Page 93: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

DELETE a Document

/kittens> If-Match: "2-d858e51453a5785bafe517b7eddc5a98"

@BradleyHolt

Page 94: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

DELETE a Document

/kittens> If-Match: "2-d858e51453a5785bafe517b7eddc5a98"/kittens>

@BradleyHolt

Page 95: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

DELETE a Document

/kittens> If-Match: "2-d858e51453a5785bafe517b7eddc5a98"/kittens> DELETE /mittens

@BradleyHolt

Page 96: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

DELETE a Document

/kittens> If-Match: "2-d858e51453a5785bafe517b7eddc5a98"/kittens> DELETE /mittensHTTP/1.1 200 OKContent-Type: application/json

{ ok: true, id: 'mittens', rev: '3-d0780627ddff7a7f536fe273100cec41'}

@BradleyHolt

Page 97: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

DELETE a Document

/kittens> If-Match: "2-d858e51453a5785bafe517b7eddc5a98"/kittens> DELETE /mittensHTTP/1.1 200 OKContent-Type: application/json

{ ok: true, id: 'mittens', rev: '3-d0780627ddff7a7f536fe273100cec41'}/kittens>

@BradleyHolt

Page 98: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

DELETE a Document

/kittens> If-Match: "2-d858e51453a5785bafe517b7eddc5a98"/kittens> DELETE /mittensHTTP/1.1 200 OKContent-Type: application/json

{ ok: true, id: 'mittens', rev: '3-d0780627ddff7a7f536fe273100cec41'}/kittens> If-Match:

@BradleyHolt

Page 99: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Replication

/kittens>

@BradleyHolt

Page 100: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Replication

/kittens> ..

@BradleyHolt

Page 101: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Replication

/kittens> ../>

@BradleyHolt

Page 102: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Replication

/kittens> ../> DELETE /kittens

@BradleyHolt

Page 103: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Replication

/kittens> ../> DELETE /kittensHTTP/1.1 200 OKContent-Type: application/json

{ ok: true }

@BradleyHolt

Page 104: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Replication

/>

@BradleyHolt

Page 105: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Replication

/> POST /_replicate

@BradleyHolt

Page 106: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Replication

/> POST /_replicate...

@BradleyHolt

Page 107: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Replication

/> POST /_replicate... { "create_target": true, "source": "https://bradley-holt.cloudant.com/kittens", "target": "kittens" }

@BradleyHolt

Page 108: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Replication

/> POST /_replicate... { "create_target": true, "source": "https://bradley-holt.cloudant.com/kittens", "target": "kittens" }HTTP/1.1 200 OKContent-Type: application/json

{ ok: true, session_id: '9f7bd286a0001ece5bf0bf65dd83c5ab', source_last_seq: '5-g1AAAAFDeJzLYWBgYMlgTmGQT0lKzi9KdUhJMtVLykxPyilN1UvOyS9NScwr0ctLLckBKmRKZEiy____f1YiA6oWQ9xakhyAZFI9SFcGcyJzLpDHbplmZmxkaULYBKIdlscCJBkagBTQov2kuA-i8wBEJ9iNTGA3mhoampmnGBA2JQsA1LtoyA', …}

@BradleyHolt

Page 109: CouchDB Day NYC 2017: Introduction to CouchDB 2.0
Page 110: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/>

@BradleyHolt

Page 111: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/> /kittens

@BradleyHolt

Page 112: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens>

@BradleyHolt

Page 113: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens> POST /_index

@BradleyHolt

Page 114: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens> POST /_index...

@BradleyHolt

Page 115: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens> POST /_index... { "index": { "fields": [ "age_weeks", "weight_kilograms" ] } }

@BradleyHolt

Page 116: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens> POST /_index... { "index": { "fields": [ "age_weeks", "weight_kilograms" ] } }HTTP/1.1 200 OKContent-Type: application/json

{ result: 'created', id: '_design/e19dde7f518129a966ebe072edc66be88d54e694', name: 'e19dde7f518129a966ebe072edc66be88d54e694'}

@BradleyHolt

Page 117: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

@BradleyHolt

Page 118: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens>

@BradleyHolt

Page 119: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens> POST /_find

@BradleyHolt

Page 120: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens> POST /_find...

@BradleyHolt

Page 121: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens> POST /_find... { "selector": { "age_weeks": { "$gte": 7, "$lte": 10 } }, "fields": [ "_id", "age_weeks" ] }

@BradleyHolt

Page 122: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens> POST /_find... { "selector": { "age_weeks": { "$gte": 7, "$lte": 10 } }, "fields": [ "_id", "age_weeks" ] }HTTP/1.1 200 OKContent-Type: application/json

{ docs: [ { _id: 'tiger', age_weeks: 7 }, { _id: 'daisy', age_weeks: 9 }, { _id: 'mittens', age_weeks: 10 } ]}

@BradleyHolt

Page 123: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

@BradleyHolt

Page 124: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens>

@BradleyHolt

Page 125: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens> POST /_find

@BradleyHolt

Page 126: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens> POST /_find...

@BradleyHolt

Page 127: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens> POST /_find... { "selector": { "age_weeks": { "$gte": 0 }, "weight_kilograms": { "$gte": 0.5, "$lte": 1 } }, "fields": [ "_id", "weight_kilograms" ] }

@BradleyHolt

Page 128: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Mango

/kittens> POST /_find... { "selector": { "age_weeks": { "$gte": 0 }, "weight_kilograms": { "$gte": 0.5, "$lte": 1 } }, "fields": [ "_id", "weight_kilograms" ] }HTTP/1.1 200 OKContent-Type: application/json

{ docs: [ { _id: 'tiger', weight_kilograms: 0.726 }, { _id: 'daisy', weight_kilograms: 0.816 }, { _id: 'mittens', weight_kilograms: 0.997 } ]}

@BradleyHolt

Page 129: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

@BradleyHolt

Page 130: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Contributing

Page 131: CouchDB Day NYC 2017: Introduction to CouchDB 2.0
Page 132: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Offline First

Page 133: CouchDB Day NYC 2017: Introduction to CouchDB 2.0
Page 134: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Offline First

Lack of connectivity is not an error condition.

Page 135: CouchDB Day NYC 2017: Introduction to CouchDB 2.0
Page 136: CouchDB Day NYC 2017: Introduction to CouchDB 2.0
Page 137: CouchDB Day NYC 2017: Introduction to CouchDB 2.0
Page 138: CouchDB Day NYC 2017: Introduction to CouchDB 2.0
Page 139: CouchDB Day NYC 2017: Introduction to CouchDB 2.0
Page 140: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Cloudant Sync

Page 141: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Cloudant FoodTracker

Page 142: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Cloudant FoodTracker

Page 143: CouchDB Day NYC 2017: Introduction to CouchDB 2.0
Page 144: CouchDB Day NYC 2017: Introduction to CouchDB 2.0
Page 145: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Cloudant Location Tracker

Page 146: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Offline Camp BerlinApril 28th - May 1st, Berlin, Germany

Page 147: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

offlinefirst.org/camp

Page 148: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Image Credits

paper by malik, on Flickr <https://flic.kr/p/aZjTXv> person by Tim Morgan, on Flickr <https://flic.kr/p/7DSF5> database by Tim Morgan, on Flickr <https://flic.kr/p/7DUk5> gear by Tim Morgan, on Flickr <https://flic.kr/p/7DSF1> Mango with section on a white background by bangdoll, on Flickr <https://flic.kr/p/9CBP2h>

@BradleyHolt

Page 149: CouchDB Day NYC 2017: Introduction to CouchDB 2.0

Questions?

@BradleyHolt