Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Offline First with
CouchDB
Offline =  Error (2014)

 

NI:  @2311 a 25211
E ’ 3;
Ffi Status l’-‘A Photo 9 Check In

 

I,  ‘it-nlnllw-nil! -1-Lu= ;-II...
Offline =  Mode (2015)

 

[/1 Slalus :5: Photo 9 Check In

'~F Herve Roussel

.3‘

Tms is an o-we Lest gruklwtg

Orelie C...
Slow ~=  Offline

llll lf. Allll. l  Alli. 

l1IlH‘. ’llt. <ll1ulll‘
‘V . -1

   

" _*.  f'_' ,  ‘, -v ‘ -. .-rs ». 
. .  - r ‘ «* --.  . . x. -- - ’ -
I ,  ..  , -. ,, -~ . ,
-.  1 - __; e....
Read/ write on any device
Offline Flow

ll SYNKWNH l
B SERVER ; 

I

l OFFLINE
‘ All

 

Credit: MarcelKalveram(http: //de. s|ideshare. net/ MarcelK...
I7

I

CouchDB

relax

+ V pouchdb
JSON Docs + HTTP API

R P R C HE

mongoDB 1 11*. 

 
     
    
 

RAVEN DE
DOCU M E NT

   

KEY—VALU E 
 C)T‘, §S%| Ee b...
”saigon—apera-house", 
"Saigon Opera House”. 
106.79.
10.75,
"sight", 
"hours":  (
"monday - {
tart" ”o9ac”, 
"end":  ”230o”
cam http: //Eouchserver/ my_t: ip£ozmi/ _a1lAdocs? inc1ude_docs= t:ue

I

"total_rows 1,
"offset":  0,

Saigon-opera-house...
. umminmuemed

Rusmsfi

l+ynenanl‘e* Jwasmr.  taemcacrueuy 3}"e‘ll: :7x“. 'lL”d'I: '3o"is‘; °."
tibia ‘scat-,  l§= n11¢. = ‘
Replication!
Insert + replicate

ma.  .| -x-Ell

In .  I:  ulfdl

«I ‘ll {.7 ; .,

‘lumen In:  1
luv

 

.  <v= u' ! Hn]ll¢llT

 

l: r...
Direct insert

curl -H ‘Content-Type:  application/ )'son' 
—x POST http: 

 

Remote
var 1oca1DB =  new PouchDB( 'my_tripforrni_local‘)
var reInoteDE =  new PouchDE( 'htlzp: //Couchsrzrvar/ rny_tripformi_rem...
Changes feed

GET

("resull: s" =  [(
vvsequ
"id" . 
"changes" :  [ ( "rev": 

. , id" . 
"changes" :  [ { "rev":  )1, "de...
Changes feed (cont. )

GET

}], "dele: ed”: true
Versioning

 

A
4}
PUT nttp: //~oueh= e»ver/ my rrwpforww/ €Jigon—np9r3—housF

(
“: ;c1e“:  "saigon Opera House (NHA HAT)“

”conf1ict". ':eas...
Conflict

5agon—opeva—hau§e
1 -aaa
.  awgon opera House

  

4
1
_m.  smgan-opera-house mpncate
rev:  nap
name‘ um rm um (...
Conflict (cont. )

Winning/ Loosing

--:9

, __> :92-a
rl ——> 592-13
‘——> r2c
$ GET http:  // scoucH_s1:nvER/ my_tzip£o: mi/ eaigon—opeza—houee? con£11cts= c:ue

{"_id“: "saigon—cpera—house“, "_rev": ...
Further reading

I CouchDB

Document validation
Indexing

Client Ul (Futon,  Fauxton)
Security

Attachments

Hosting (iris...
Offline =  Feature

_ Kornel IQ!  Following
pornelskl

What if browsers instead of showing "Error: 
you're offline" displa...
Thank you! 

Herve Roussel

>-> hrousse| @tripformi. com
9- @hvroussel
+ linkedin. com/ in/ hroussel

>+ ange| .co/ hrouss...
Upcoming SlideShare
Loading in …5
×

Offline First with CouchDB

2,488 views

Published on

Offline First with CouchDB for Grokking HCMC #4

Published in: Technology
  • Be the first to comment

Offline First with CouchDB

  1. 1. Offline First with CouchDB
  2. 2. Offline = Error (2014) NI: @2311 a 25211 E ’ 3; Ffi Status l’-‘A Photo 9 Check In I, ‘it-nlnllw-nil! -1-Lu= ;-III-J1I
  3. 3. Offline = Mode (2015) [/1 Slalus :5: Photo 9 Check In '~F Herve Roussel .3‘ Tms is an o-we Lest gruklwtg Orelie Cathaud added 6 new photos. ~: we . A Lovely Sunday anemoon m FlIchrnond; )
  4. 4. Slow ~= Offline llll lf. Allll. l Alli. l1IlH‘. ’llt. <ll1ulll‘
  5. 5. ‘V . -1 " _*. f'_' , ‘, -v ‘ -. .-rs ». . . - r ‘ «* --. . . x. -- - ’ - I , .. , -. ,, -~ . , -. 1 - __; e. _ . .1 ' ‘ * — - . , , , . - - ' ‘ ' ~ ‘ ‘ '. . - ~v. _ , 5 -e U. ‘ ‘ ¢ "’-. . . ' r4 ' . v -* ‘ ,4 , . .1, ~ - ‘ _ _w. .tmg luv WWW r. o.mx mm r . .
  6. 6. Read/ write on any device
  7. 7. Offline Flow ll SYNKWNH l B SERVER ; I l OFFLINE ‘ All Credit: MarcelKalveram(http: //de. s|ideshare. net/ MarcelKslveram/ offlrne—first—1herpaln| ess—way)
  8. 8. I7 I CouchDB relax + V pouchdb
  9. 9. JSON Docs + HTTP API R P R C HE mongoDB 1 11*. RAVEN DE DOCU M E NT KEY—VALU E C)T‘, §S%| Ee basho GRAPH ET’ redis
  10. 10. ”saigon—apera-house", "Saigon Opera House”. 106.79. 10.75, "sight", "hours": ( "monday - { tart" ”o9ac”, "end": ”230o”
  11. 11. cam http: //Eouchserver/ my_t: ip£ozmi/ _a1lAdocs? inc1ude_docs= t:ue I "total_rows 1, "offset": 0, Saigon-opera-house”, "saigon—opera—house": "saigon—opeza—house", “Saigon Opera House", 105.78. 10.75, "type “Sight” "hours": ( ”monday' ( "start ”o9oo”. “end”: "2300" £unc: iDn(do: ) ( emit(doc. type, doc. name); I GET http: //(; coL£‘. ‘.* ; - I - w-r[.1_: oo~_ ~. v,r, »./ C/ ;>L: ?kuy LLL1
  12. 12. . umminmuemed Rusmsfi l+ynenanl‘e* Jwasmr. taemcacrueuy 3}"e‘ll: :7x“. 'lL”d'I: '3o"is‘; °." tibia ‘scat-, l§= n11¢. = ‘
  13. 13. Replication!
  14. 14. Insert + replicate ma. .| -x-Ell In . I: ulfdl «I ‘ll {.7 ; ., ‘lumen In: 1 luv . <v= u' ! Hn]ll¢llT l: r—‘“ I-1-f-‘I = ; .4a: !I'k-r. aa= . :1-1("‘7iiE’a91'I-L-1'! -Ii Local Rel-Flicale Remote r~w, .»i; at ui1,_1m-nv-)1 = :.-I-. ;.r1ou_; a-tggz-; ... iL_; ¢=mg-or-, . 4
  15. 15. Direct insert curl -H ‘Content-Type: application/ )'son' —x POST http: Remote
  16. 16. var 1oca1DB = new PouchDB( 'my_tripforrni_local‘) var reInoteDE = new PouchDE( 'htlzp: //Couchsrzrvar/ rny_tripformi_remot: n‘) locs1DB. sync{relIval; eDB). on('complete‘, function () { / / yay, were 11') syncl )). on(‘error‘, function (err) { / / boo, -lg . + an error! ll; POST / _2eplicat: e HTTP/1. l { “source“ : "my_tripforrni_local“ , “ target " : " http: / / couchserver/ my_eripfomi_remofe " )
  17. 17. Changes feed GET ("resull: s" = [( vvsequ "id" . "changes" : [ ( "rev": . , id" . "changes" : [ { "rev": )1, "deleted" : true } ] : ''1ast_5eq'' : ')
  18. 18. Changes feed (cont. ) GET }], "dele: ed”: true
  19. 19. Versioning A 4}
  20. 20. PUT nttp: //~oueh= e»ver/ my rrwpforww/ €Jigon—np9r3—housF ( “: ;c1e“: "saigon Opera House (NHA HAT)“ ”conf1ict". ':eason Document update conf1ict. "} PUT http: //an-M~, hservt>r/ :'*V enesomu/ ea‘ ( “_rev“: "1—z9o219155s" “title“. "Saigon Opera House {NH}; HAT)“ curl x rum http " 90219155
  21. 21. Conflict 5agon—opeva—hau§e 1 -aaa . awgon opera House 4 1 _m. smgan-opera-house mpncate rev: nap name‘ um rm um (hlnh rephcate JG: sagon—apera—huu5e _: a; 5aigon—opera—hou5e rev- 2—hh| : rev- 2—u: c Ham "Mhi rm Lon norm name Saigon open House mm rm mu mama) _ru agnn—np2va—house rev 1-aaa name sargen opera Hpuse _ra. smgan-opera-house rev: 2<: : name‘ Sulgnn opera Home mm rm | .6n mam-1
  22. 22. Conflict (cont. ) Winning/ Loosing --:9 , __> :92-a rl ——> 592-13 ‘——> r2c
  23. 23. $ GET http: // scoucH_s1:nvER/ my_tzip£o: mi/ eaigon—opeza—houee? con£11cts= c:ue {"_id“: "saigon—cpera—house“, "_rev": "2—ccc“, “s: ree:1-xddrees": "saigon Opera House ( "_conf11cts" : [ "2-aaa" , ''2»bbb'' ]) 5 GET http: //SCOUCI-I_SEl1VER/ my_tzipfozmi/ Haiqon—opera—honHe? rev— -aaa
  24. 24. Further reading I CouchDB Document validation Indexing Client Ul (Futon, Fauxton) Security Attachments Hosting (iriscouch, cloudant) Offline Frameworks (hoodie) Geospatial queries I PouchDB I NodeJS(Leve| Up) I PouchDB Server I Native for iOS, Android
  25. 25. Offline = Feature _ Kornel IQ! Following pornelskl What if browsers instead of showing "Error: you're offline" displayed "This website doesn't support offline usage (yet? )" ; EgwEErS ZXQOFHTES n W ‘ ' a 8:24 PM - 24 Jun 2015
  26. 26. Thank you! Herve Roussel >-> hrousse| @tripformi. com 9- @hvroussel + linkedin. com/ in/ hroussel >+ ange| .co/ hroussel >-Ir» s| ideshare. com/ hroussel

×