SlideShare a Scribd company logo
Lab: JSON Documents (30 minutes)
Bradley Holt, Developer Advocate
Thursday, February 9, 2017
CouchDB Developer Day
@BradleyHolt
JSON Documents
{
_id: "6EF9D2B0-13D3-1378-8D30-39E3CE0B36C2",
_rev: "1-0b457efcf82fb29492ef927ba5b6ee15",
type: "Feature",
geometry: {
type: "Point",
coordinates: [
-71.1028,
42.3691
]
},
properties: {
session_id: "3486b13f-7b8a-8a96-dfbf-9b82800e367f",
timestamp: 1422928591717
}
}
@BradleyHolt
http-console
$ npm install http-console -g
@BradleyHolthttps://github.com/cloudhead/http-console
http-console
$ npm install http-console -g
$ http-console 127.0.0.1:5984
@BradleyHolthttps://github.com/cloudhead/http-console
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
Connecting to CouchDB 2.0
$ http-console root:passw0rd@127.0.0.1:5984 --json
@BradleyHolt
Connecting to CouchDB 2.0
$ http-console root:passw0rd@127.0.0.1:5984 --json
> http-console 0.6.3
> Welcome, enter .help if you're lost.
> Connecting to 127.0.0.1 on port 5984.
@BradleyHolt
Connecting to IBM Cloudant
$ http-console https://bradley-holt:passw0rd@bradley-holt.cloudant.com --json
@BradleyHolt
Connecting to IBM Cloudant
$ http-console https://bradley-holt:passw0rd@bradley-holt.cloudant.com --json
> http-console 0.6.3
> Welcome, enter .help if you're lost.
> Connecting to bradley-holt.cloudant.com on port 443.
@BradleyHolt
PUT a Database
/>
@BradleyHolt
PUT a Database
/> PUT /kittens
@BradleyHolt
PUT a Database
/> PUT /kittens
...
@BradleyHolt
PUT a Database
/> PUT /kittens
...
HTTP/1.1 201 Created
Content-Type: application/json
Location: http://127.0.0.1/kittens
{ ok: true }
@BradleyHolt
POST a Document
/>
@BradleyHolt
POST a Document
/> /kittens
@BradleyHolt
POST a Document
/kittens>
@BradleyHolt
POST a Document
/kittens> POST /
@BradleyHolt
POST a Document
/kittens> POST /
...
@BradleyHolt
POST a Document
/kittens> POST /
... { "_id": "mittens", "age_weeks": 10, "weight_kilograms": 0.997 }
@BradleyHolt
POST a Document
/kittens> POST /
... { "_id": "mittens", "age_weeks": 10, "weight_kilograms": 0.997 }
HTTP/1.1 201 Created
Content-Type: application/json
Location: http://127.0.0.1/kittens/mittens
{
ok: true,
id: 'mittens',
rev: '1-e665a40d9ea9711c983e907f0b0b6e8a'
}
@BradleyHolt
GET All Documents
/kittens>
@BradleyHolt
GET All Documents
/kittens> GET /_all_docs
@BradleyHolt
GET All Documents
/kittens> GET /_all_docs
HTTP/1.1 200 OK
Content-Type: application/json
Etag: "92afa0f309a9fd9f140cd31ff5000b5c"
{
total_rows: 1,
offset: 0,
rows: [
{
id: 'mittens',
key: 'mittens',
value: { rev: '1-e665a40d9ea9711c983e907f0b0b6e8a' }
}
]
}
@BradleyHolt
GET a Document
/kittens>
@BradleyHolt
GET a Document
/kittens> GET /mittens
@BradleyHolt
GET a Document
/kittens> GET /mittens
HTTP/1.1 200 OK
Content-Type: application/json
Etag: "1-e665a40d9ea9711c983e907f0b0b6e8a"
{
_id: 'mittens',
_rev: '1-e665a40d9ea9711c983e907f0b0b6e8a',
age_weeks: 10,
weight_kilograms: 0.997
}
@BradleyHolt
PUT an Attachment
/kittens>
@BradleyHolt
PUT an Attachment
/kittens> .headers
@BradleyHolt
PUT an Attachment
/kittens> .headers
Accept: application/json
Content-Type: application/json
Authorization: Basic cm9vdDorMi95N3Y2aA==
Host: 127.0.0.1
@BradleyHolt
PUT an Attachment
/kittens> .headers
Accept: application/json
Content-Type: application/json
Authorization: Basic cm9vdDorMi95N3Y2aA==
Host: 127.0.0.1
/kittens> Content-Type: image/gif
@BradleyHolt
PUT an Attachment
/kittens>
@BradleyHolt
PUT an Attachment
/kittens> PUT /mittens/photo?rev=1-e665a40d9ea9711c983e907f0b0b6e8a
@BradleyHolt
PUT an Attachment
/kittens> PUT /mittens/photo?rev=1-e665a40d9ea9711c983e907f0b0b6e8a
...
@BradleyHolt
PUT an Attachment
/kittens> PUT /mittens/photo?rev=1-e665a40d9ea9711c983e907f0b0b6e8a
... R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=
@BradleyHolt
PUT an Attachment
/kittens> PUT /mittens/photo?rev=1-e665a40d9ea9711c983e907f0b0b6e8a
... R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=
HTTP/1.1 201 Created
Content-Type: application/json
Location: http://127.0.0.1/kittens/mittens/photo
{
ok: true,
id: 'mittens',
rev: '2-d858e51453a5785bafe517b7eddc5a98'
}
@BradleyHolt
PUT an Attachment
/kittens> PUT /mittens/photo?rev=1-e665a40d9ea9711c983e907f0b0b6e8a
... R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=
HTTP/1.1 201 Created
Content-Type: application/json
Location: http://127.0.0.1/kittens/mittens/photo
{
ok: true,
id: 'mittens',
rev: '2-d858e51453a5785bafe517b7eddc5a98'
}
/kittens>
@BradleyHolt
PUT an Attachment
/kittens> PUT /mittens/photo?rev=1-e665a40d9ea9711c983e907f0b0b6e8a
... R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=
HTTP/1.1 201 Created
Content-Type: application/json
Location: http://127.0.0.1/kittens/mittens/photo
{
ok: true,
id: 'mittens',
rev: '2-d858e51453a5785bafe517b7eddc5a98'
}
/kittens> Content-Type: application/json
@BradleyHolt
GET an Attachment
/kittens>
@BradleyHolt
GET an Attachment
/kittens> GET /mittens/photo
@BradleyHolt
GET an Attachment
/kittens> GET /mittens/photo
HTTP/1.1 200 OK
Content-Type: image/gif
Etag: "UsqjdPnY6ApD2ENFOglFHg=="
R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=
@BradleyHolt
Conditional Caching
/kittens>
@BradleyHolt
Conditional Caching
/kittens> If-None-Match: "UsqjdPnY6ApD2ENFOglFHg=="
@BradleyHolt
Conditional Caching
/kittens> If-None-Match: "UsqjdPnY6ApD2ENFOglFHg=="
/kittens>
@BradleyHolt
Conditional Caching
/kittens> If-None-Match: "UsqjdPnY6ApD2ENFOglFHg=="
/kittens> GET /mittens/photo
@BradleyHolt
Conditional Caching
/kittens> If-None-Match: "UsqjdPnY6ApD2ENFOglFHg=="
/kittens> GET /mittens/photo
HTTP/1.1 304 Not Modified
@BradleyHolt
Conditional Caching
/kittens> If-None-Match: "UsqjdPnY6ApD2ENFOglFHg=="
/kittens> GET /mittens/photo
HTTP/1.1 304 Not Modified
/kittens>
@BradleyHolt
Conditional Caching
/kittens> If-None-Match: "UsqjdPnY6ApD2ENFOglFHg=="
/kittens> GET /mittens/photo
HTTP/1.1 304 Not Modified
/kittens> If-None-Match:
@BradleyHolt
DELETE a Document
/kittens>
@BradleyHolt
DELETE a Document
/kittens> DELETE /mittens
@BradleyHolt
DELETE a Document
/kittens> DELETE /mittens
HTTP/1.1 409 Conflict
Content-Type: application/json
{ error: 'conflict', reason: 'Document update conflict.' }
@BradleyHolt
DELETE a Document
/kittens>
@BradleyHolt
DELETE a Document
/kittens> HEAD /mittens
@BradleyHolt
DELETE a Document
/kittens> HEAD /mittens
HTTP/1.1 200 OK
Etag: "2-d858e51453a5785bafe517b7eddc5a98"
@BradleyHolt
DELETE a Document
/kittens>
@BradleyHolt
DELETE a Document
/kittens> If-Match: "2-d858e51453a5785bafe517b7eddc5a98"
@BradleyHolt
DELETE a Document
/kittens> If-Match: "2-d858e51453a5785bafe517b7eddc5a98"
/kittens>
@BradleyHolt
DELETE a Document
/kittens> If-Match: "2-d858e51453a5785bafe517b7eddc5a98"
/kittens> DELETE /mittens
@BradleyHolt
DELETE a Document
/kittens> If-Match: "2-d858e51453a5785bafe517b7eddc5a98"
/kittens> DELETE /mittens
HTTP/1.1 200 OK
Content-Type: application/json
{
ok: true,
id: 'mittens',
rev: '3-d0780627ddff7a7f536fe273100cec41'
}
@BradleyHolt
DELETE a Document
/kittens> If-Match: "2-d858e51453a5785bafe517b7eddc5a98"
/kittens> DELETE /mittens
HTTP/1.1 200 OK
Content-Type: application/json
{
ok: true,
id: 'mittens',
rev: '3-d0780627ddff7a7f536fe273100cec41'
}
/kittens>
@BradleyHolt
DELETE a Document
/kittens> If-Match: "2-d858e51453a5785bafe517b7eddc5a98"
/kittens> DELETE /mittens
HTTP/1.1 200 OK
Content-Type: application/json
{
ok: true,
id: 'mittens',
rev: '3-d0780627ddff7a7f536fe273100cec41'
}
/kittens> If-Match:
@BradleyHolt
Delete the Database
/>
@BradleyHolt
Delete the Database
/> DELETE /kittens
@BradleyHolt
Delete the Database
/> DELETE /kittens
HTTP/1.1 200 OK
Content-Type: application/json
{ ok: true }
@BradleyHolt
Try It On Your Own
1. Create a database
2. Create a document in the database
3. Read the document
4. Update the document
5. Delete the document
6. Delete the database
@BradleyHolt
Lab: JSON Documents
CouchDB Developer Day
@BradleyHolt

More Related Content

PPTX
CouchDB Day NYC 2017: Mango
PPTX
CouchDB Day NYC 2017: Replication
PPTX
CouchDB Day NYC 2017: MapReduce Views
PPTX
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
PPTX
CouchDB Day NYC 2017: Full Text Search
PDF
Productivity tips for developers
PPT
Realtime Analytics Using MongoDB, Python, Gevent, and ZeroMQ
PDF
PuppetDB: A Single Source for Storing Your Puppet Data - PUG NY
CouchDB Day NYC 2017: Mango
CouchDB Day NYC 2017: Replication
CouchDB Day NYC 2017: MapReduce Views
CouchDB Day NYC 2017: Introduction to CouchDB 2.0
CouchDB Day NYC 2017: Full Text Search
Productivity tips for developers
Realtime Analytics Using MongoDB, Python, Gevent, and ZeroMQ
PuppetDB: A Single Source for Storing Your Puppet Data - PUG NY

What's hot (20)

PDF
Webscraping with asyncio
PDF
Tupperware
PDF
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
PDF
Scrapy workshop
PDF
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
PDF
Pydata-Python tools for webscraping
PDF
Web Scrapping with Python
PPTX
Build javascript in private environment
PPTX
git internals
PDF
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
PDF
Git the Docs: A fun, hands-on introduction to version control
PDF
Spatial script for my JS.Everywhere 2012
PPTX
Deploying E.L.K stack w Puppet
PDF
Docker for data science
ODT
Spatial script for MongoBoulder
PDF
PDF
Prototyping in the cloud
PPTX
2015 555 kharchenko_ppt
PDF
Py conkr 20150829_docker-python
PPTX
Javascript - The Stack and Beyond
Webscraping with asyncio
Tupperware
Got Logs? Get Answers with Elasticsearch ELK - PuppetConf 2014
Scrapy workshop
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Pydata-Python tools for webscraping
Web Scrapping with Python
Build javascript in private environment
git internals
How to Scrap Any Website's content using ScrapyTutorial of How to scrape (cra...
Git the Docs: A fun, hands-on introduction to version control
Spatial script for my JS.Everywhere 2012
Deploying E.L.K stack w Puppet
Docker for data science
Spatial script for MongoBoulder
Prototyping in the cloud
2015 555 kharchenko_ppt
Py conkr 20150829_docker-python
Javascript - The Stack and Beyond
Ad

Viewers also liked (20)

PPTX
dashDB: the GIS professional’s bridge to mainstream IT systems
PDF
Cloud Data Services: A Brand New Ballgame for Business
PDF
JSON-RPC Proxy Generation with PHP 5
PPT
RESTful JSON web databases
PPTX
Мероприятия как инструмент работы с молодыми специалистами и продвижения брен...
PPT
Advanced Json
PDF
Uncle Ben's Recipe Video Contest Flyer
PPT
Seattle SeaHawks
DOC
Mars
PPTX
CouchDB Day NYC 2017: Using Geospatial Data in Cloudant & CouchDB
ODP
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
PPT
Mars Business report
PPT
Sara's m&m slideshow
PPTX
03 json for java script
PPTX
The JSON REST API for WordPress
PPTX
PPT
Mars incorporated interview questions and answers
PDF
Customer Success Story: Mars Inc. [New York]
PPTX
M&M's case study
PPTX
WALTHAM Puppy Growth Charts
dashDB: the GIS professional’s bridge to mainstream IT systems
Cloud Data Services: A Brand New Ballgame for Business
JSON-RPC Proxy Generation with PHP 5
RESTful JSON web databases
Мероприятия как инструмент работы с молодыми специалистами и продвижения брен...
Advanced Json
Uncle Ben's Recipe Video Contest Flyer
Seattle SeaHawks
Mars
CouchDB Day NYC 2017: Using Geospatial Data in Cloudant & CouchDB
HTTP, JSON, JavaScript, Map&Reduce built-in to MySQL
Mars Business report
Sara's m&m slideshow
03 json for java script
The JSON REST API for WordPress
Mars incorporated interview questions and answers
Customer Success Story: Mars Inc. [New York]
M&M's case study
WALTHAM Puppy Growth Charts
Ad

Similar to CouchDB Day NYC 2017: JSON Documents (20)

PDF
Apache CouchDB talk at Ontario GNU Linux Fest
PPTX
CouchDB Day NYC 2017: Core HTTP API
KEY
Couchdb: No SQL? No driver? No problem
PDF
Introduction to CouchDB
KEY
CouchDB : More Couch
PDF
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
KEY
OSCON 2011 Learning CouchDB
KEY
OSCON 2011 CouchApps
ODP
CouchApp - Build scalable web applications and relax
PDF
Advanced CouchDB phpday.it
PDF
Python-CouchDB Training at PyCon PL 2012
PDF
CouchDB Mobile - From Couch to 5K in 1 Hour
PDF
Agile Document Models & Data Structures
PDF
Introduction to CouchDB - LA Hacker News
PDF
03. ElasticSearch : Data In, Data Out
PDF
Advanced CouchDB Rotterdam.rb July 2010
PDF
CouchDB in The Room
PDF
Managing Your Content with Elasticsearch
ODP
Introducing CouchDB
PDF
Couchdb w Ruby'm
Apache CouchDB talk at Ontario GNU Linux Fest
CouchDB Day NYC 2017: Core HTTP API
Couchdb: No SQL? No driver? No problem
Introduction to CouchDB
CouchDB : More Couch
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
OSCON 2011 Learning CouchDB
OSCON 2011 CouchApps
CouchApp - Build scalable web applications and relax
Advanced CouchDB phpday.it
Python-CouchDB Training at PyCon PL 2012
CouchDB Mobile - From Couch to 5K in 1 Hour
Agile Document Models & Data Structures
Introduction to CouchDB - LA Hacker News
03. ElasticSearch : Data In, Data Out
Advanced CouchDB Rotterdam.rb July 2010
CouchDB in The Room
Managing Your Content with Elasticsearch
Introducing CouchDB
Couchdb w Ruby'm

More from IBM Cloud Data Services (13)

PDF
Practical Use of a NoSQL
PPTX
I See NoSQL Document Stores in Geospatial Applications
PPTX
Webinar: The Anatomy of the Cloudant Data Layer
PPTX
NoSQL for SQL Users
PPTX
Practical Use of a NoSQL Database
PPTX
SQL To NoSQL - Top 6 Questions Before Making The Move
PPTX
Machine Learning with Apache Spark
PPTX
Mobile App Development With IBM Cloudant
PPT
IBM Cognos Business Intelligence using dashDB
PPTX
Run Oracle Apps in the Cloud with dashDB
PDF
Analyzing GeoSpatial data with IBM Cloud Data Services & Esri ArcGIS
PDF
Get Started Quickly with IBM's Hadoop as a Service
PDF
Introducing dashDB MPP: The Power of Data Warehousing in the Cloud
Practical Use of a NoSQL
I See NoSQL Document Stores in Geospatial Applications
Webinar: The Anatomy of the Cloudant Data Layer
NoSQL for SQL Users
Practical Use of a NoSQL Database
SQL To NoSQL - Top 6 Questions Before Making The Move
Machine Learning with Apache Spark
Mobile App Development With IBM Cloudant
IBM Cognos Business Intelligence using dashDB
Run Oracle Apps in the Cloud with dashDB
Analyzing GeoSpatial data with IBM Cloud Data Services & Esri ArcGIS
Get Started Quickly with IBM's Hadoop as a Service
Introducing dashDB MPP: The Power of Data Warehousing in the Cloud

Recently uploaded (20)

PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
AI in Product Development-omnex systems
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Digital Strategies for Manufacturing Companies
PPTX
ai tools demonstartion for schools and inter college
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
top salesforce developer skills in 2025.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Essential Infomation Tech presentation.pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Odoo Companies in India – Driving Business Transformation.pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
AI in Product Development-omnex systems
Odoo POS Development Services by CandidRoot Solutions
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
2025 Textile ERP Trends: SAP, Odoo & Oracle
Digital Strategies for Manufacturing Companies
ai tools demonstartion for schools and inter college
Softaken Excel to vCard Converter Software.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
top salesforce developer skills in 2025.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Wondershare Filmora 15 Crack With Activation Key [2025
How to Choose the Right IT Partner for Your Business in Malaysia
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Essential Infomation Tech presentation.pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Odoo Companies in India – Driving Business Transformation.pdf

CouchDB Day NYC 2017: JSON Documents

Editor's Notes

  • #3: CouchDB is a document database JSON objects with a few special field names _id field represents unique identifier for a document _rev field is the revision marker for a document _rev field is used for Multi-Version Concurrency Control, a form of optimistic concurrency
  • #7: HTTP Basic authentication is a simple way to authenticate with an HTTP server Other approaches, such as cookies and OAuth, are often used as well
  • #31: Resources can be represented in different content types