Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Apache CouchDB
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Myles Braithwaite
September 09, 2014
Technology
47
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Apache CouchDB
Myles Braithwaite
September 09, 2014
More Decks by Myles Braithwaite
See All by Myles Braithwaite
pgloader
myles
0
78
IndieWeb - The person-focused alternative to the corporate web
myles
0
190
Let's Encrypt All the Things
myles
1
130
Chat Bots
myles
1
160
Ansible: Orchestrate Your Infustrature Like Gustav Mahler
myles
0
220
PostgresDoc: Using Postgres as a Document Oriented Database
myles
0
210
Take a Stroll in the Bazaar
myles
0
150
LessCSS
myles
0
52
jrnl
myles
0
51
Other Decks in Technology
See All in Technology
QAエンジニア起点で進める、SmartHRにおける信頼性向上について
kaomi_wombat
1
140
2026-08-15 JAWS-UG 茨城 #16 Secrets ManagerにおけるSecret値の管理(Terraformの場合) / Secrets Manager Secrets
masasuzu
0
110
【AG-UI × A2UI × MCP Apps】Generative UIをやさしく解説する
nrinetcom
PRO
1
140
Model Studio CLI × Token Plan
maigo999
0
180
JavaScript 研修 (2026)
recruitengineers
PRO
2
580
認知負荷をGemini で溶かす — GKE 基盤「Orbit」における AI エージェントの実践
sansantech
PRO
1
310
Bits Agent Builder の⼊⾨と活⽤事例
nulabinc
PRO
0
160
侵入は突然に 〜 IoTマルウェアと悪用される家庭の機器 ~ / When Intrusion Strikes: IoT Malware and the Abuse of Home Devices
nttcom
0
5.9k
AIのためのEthernet技術動向 (SerDes)
markunet
1
100
PLATEAU で バーチャル花火大会
tatsuya1970
0
160
なぜ Temporal の大小比較には compare しかないのか / Why Does Temporal Only Have compare() for Comparisons
kazukihayase
1
130
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.2k
Featured
See All Featured
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
Chasing Engaging Ingredients in Design
codingconduct
0
270
The Cost Of JavaScript in 2023
addyosmani
55
10k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
280
How to make the Groovebox
asonas
2
2.3k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.3k
Typedesign – Prime Four
hannesfritz
42
3.1k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
370
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
610
SEO for Brand Visibility & Recognition
aleyda
0
4.7k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
630
Transcript
Apache CouchDB Myles Braithwaite
[email protected]
| http://mylesb.ca | @mylesb
What is CouchDB?
Apache CouchDB is a database that uses JSON for documents,
JavaScript for MapReduce indexes, and regular HTTP for its API.
Django may be built for the Web, but CouchDB is
built of the Web. — Jacob Kaplan-Moss, Django Developer
Document Based Key/Value Store Unlike a relational database (i.e. Postgres
& MySQL), CouchDB doesn’t store it’s data and relationships in tables. Instead, each database is a collection of independent JSON documents.
Data Types — "string": "abcdefghijklmnopqrstuvwxyz" — "number": 123 — "float":
123.45 — "dict": {} — "list": [] — "bool": true
{ "_id": "30b0ed91384411e4af34c42c03094720", "_rev": "1-3573aeb5384411e4b121c42c03094720", "name": { "given_name": "Myles", "family_name":
"Braithwaite" }, "emails": [ { "type": "personal", "email": "
[email protected]
" }, { "type": "work", "email": "
[email protected]
" } ] }
HTTP Based API for Interacting with your Data — Create
= INSERT = PUT — Retrieve = SELECT = GET — Update = UPDATE = POST — Delete = DELETE = DELETE
Examples — Written in Python using the Kenneth Reitz's requests
library. from myles_custom_urllib_parse import urljoin from requests import get, post, put, delete, request COUCHDB_URL = "http://127.0.0.1:5984/" DB_NAME = "contacts"
r = requests.get(COUCHDB_URL) print r.json() { "couchdb": "Welcome", "uuid": "f9d2966e384711e499cfc42c03094720",
"vendor": { "name": "The Apache Software Foundation", "version": "1.4.0" }, "version": "1.4.0" }
Create a Database r = put(urljoin(COUCHDB_URL, DB_NAME)) if not r.status_code
== 201: print ERROR_RESPONSE[r.status_code] print r.json() {"ok": true}
Create data = {"name": {"first_name": "Myles", "last_name": "Braithwaite"}} r =
post(urljoin(COUCHDB_URL, DB_NAME), data) if not r.status_code == 201: print ERROR_RESPONSE[r.status_code] print r.json() {"ok": true, "id": "30b0ed91384411e4af34c42c03094720", "rev": "1-3573aeb5384411e4b121c42c03094720"}
Create (with a non-automatic ID) data = {"name": {"first_name": "Myles",
"last_name": "Braithwaite"}} DOC_ID = "9999-myles-braithwaite" r = put(urljoin(COUCHDB_URL, DB_NAME, DOC_ID), data) if not r.status_code == 201: print ERROR_RESPONSE[r.status_code] print r.json() {"ok": true, "id": "30b0ed91384411e4af34c42c03094720", "rev": "1-3573aeb5384411e4b121c42c03094720"}
Retrieve DOC_ID = "30b0ed91384411e4af34c42c03094720" r = get(urljoin(COUCHDB_URL, DB_NAME, DOC_ID)) if
not r.ok: print ERROR_RESPONSE[r.status_code] r.json()
Update DOC_ID = "30b0ed91384411e4af34c42c03094720" r = get(urljoin(COUCHDB_URL, DB_NAME, DOC_ID)) data
= r.json() data['emails']: [ { "type": "Personal", "email": "
[email protected]
", "type": "Work", "email": "
[email protected]
" } ] r = post(urljoin(COUCHDB_URL, DB_NAME, DOC_ID), data) if r.ok: print ERROR_RESPONSE[r.status_code] r.json() {"ok": true, "id": "30b0ed91384411e4af34c42c03094720", "rev": "2-f57cf4d1384a11e4a3edc42c03094720"}
Delete DOC_ID = "myles-braithwaite" r = delete( urljoin(COUCHDB_URL, DB_NAME, DOC_ID)
+ "?rev=%s" % DOC_REV) )
Attachment curl -vX \ PUT $COUCHDB_URL/$DB_NAME/$DOC_ID/headshot.jpg?rev=$REV \ --data-binary @avatar.jpg -H
"Content-Type: image/jpg"
Copy r = request( 'COPY', urljoin(COUCHDB_URL, DB_NAME, DOC_ID), {'destination': 'new-document'}
)
Other Features — Replication — Document Revisions — Futon (similar
to PHPMyAdmin) — Auth (Basic, Cookie, Database) — JavaScript based Map/Reduce
PouchDB
JavaScript clone of CouchDB that can run well within a
web browser.
var db = new PouchDB('contacts'); db.put({ _id: 'myles-braithwaite', first_name: 'Myles',
last_name: 'Braithwaite' }) db.replicate.to('http://127.0.0.1:5984/contacts/)
Questions