Apache CouchDB /

IBM Cloudant

Upkar Lidder

Developer Advocate, IBM 


> ulidder@us.ibm.com
> @lidderupk
> upkarlidder.com/talks

 

IBM Cloud Sign up - https://ibm.biz/Bdqn4r

Get started with IBM Cloudant

@lidderupk
IBM Developer

1. Create IBM Cloud Account using THIS URL

3. Create a Cloudant Service from the Catalog - use Lite plan (you can have only one lite service with the free account)

2. Check your email and activate your account. Once activated, log back into your IBM Cloud account using the link above.

FINALLY - Download Postman -  https://www.getpostman.com/downloads/

@lidderupk
IBM Developer

IBM Code Patterns - Databases

@lidderupk
IBM Developer
@lidderupk
IBM Developer

💕

Document Database

@lidderupk
IBM Developer

Apache CouchDB is a JSON document database

@lidderupk
IBM Developer
@lidderupk
IBM Developer

What is this NoSQL - it's not SQL for sure 🤣

@lidderupk
IBM Developer

Person table in RDBMS

@lidderupk
IBM Developer

Person in RDBMS 👉🏽 Person in Cloudant

@lidderupk
IBM Developer

http://nosql-database.org/

> 255 NoSQL databases

https://en.wikipedia.org/wiki/NoSQL

Are there any others ? - oh yea ! LOTS 🖖🏽

 👀

Apache CouchDB - What is a document ?

@lidderupk
IBM Developer

Apache CouchDB - what is a database ?

@lidderupk
IBM Developer

HTTP API - made for of the web 🙆🏽‍♀️

@lidderupk
IBM Developer

Database

Document

GET /_all_dbs
PUT /$dbname
DEL /$dbname
GET /$dbname
GET /$dbname/_all_docs
GET /$dbname/_id
DEL /$dbname/_id?rev_id

Try it

out !

@lidderupk
IBM Developer

Get started with IBM Cloudant

@lidderupk
IBM Developer

1. Create IBM Cloud Account using THIS URL

3. Create a Cloudant Service from the Catalog - use Lite plan (you can have only one lite service with the free account)

2. Check your email and activate your account. Once activated, log back into your IBM Cloud account using the link above.

FINALLY - Download Postman -  https://www.getpostman.com/downloads/

Get started with IBM Cloudant

@lidderupk
IBM Developer

Pick "Use both legacy credentials and IAM"

Get started with IBM Cloudant

@lidderupk
IBM Developer

4. Copy your username, password and host. We will use them later to set Postman up.

5. Click on "Manage" and "Launch Cloudant"

Get started with IBM Cloudant

@lidderupk
IBM Developer

6. Create a new database. Call it users. Remember this name, we will use it later.

7. Create a new document inside the database

Get started with IBM Cloudant

@lidderupk
IBM Developer

8. Add JSON to the new document

Workshop

@lidderupk
IBM Developer

Step 1 - import JSON into postman

@lidderupk
IBM Developer

Step 2 - set username, password, url and dbname

@lidderupk
IBM Developer

Step 3 - try our some of the calls on the left !

@lidderupk
IBM Developer

Step 4 - bulk insert documents from json to Cloudant

@lidderupk
IBM Developer

This is cool - but how do I query ? 🤺

@lidderupk
IBM Developer
Map/Reduce
Lucene
Mango
_all_docs
_id

Map / Reduce

@lidderupk
IBM Developer

Map emits / returns a key and value pair

Reduce can be used to aggregate the values emitted by the map function

_sum
_count
_stat
_approx_count_distinct
 

Ex1: Get all country / a country - map

@lidderupk
IBM Developer

Ex2: Get #people by country - reduce _count

Ex3: Average age by country - mapreduce _stats

Ex4: Count gender by country - _count

[["Afghanistan","Male"]]
%5b%5b%22Afghanistan%22%2c%22Male%22%5d%5d

Easy Replication - local ↔️ remote

Is HTTP my only option ? 

CURL - every operation has an endpoint https://ibm.biz/cloudant-api


Javascript - npm install --save @cloudant/cloudant


Java - java-cloudant


Python - pip install cloudant


Swift - pod 'SwiftCloudant'
Cloudant Documentation - https://ibm.biz/cloudant-api

CouchDB Documentation - 
https://docs.couchdb.org/en/stable/api/index.html

Apache CouchDB -  RECAP

  • schema-free document model

  • immutable documents, nothing is deleted, everything is appended

  • each document is JSON

Data

Map Reduce

HTTP Based

  • pre-computed and ran on demand
  • built iteratively as data comes in
  • written in JavaScript

Easy Replication

Thank you

 

Let's chat !

@lidderupk
IBM Developer

Upkar Lidder, IBM

 

@lidderupk

https://github.com/lidderupk/

ulidder@us.ibm.com

@lidderupk
IBM Developer
Made with Slides.com