Online Training - Couchbase Mobile 101

1,092 views
927 views

Published on

Learn the architecture around the new Couchbase mobile solution using Couchbase, Couchbase Sync Gateway and Couchbase Lite. Understand how it all fits together, and how data is moved from server to devices and back. Learn about sync functions and the parameters for setting up sync channels and permissions. Demo will be creating an instance of Couchbase/Sync Gateway on CouchbaseCloud.com and setting up and running a sample application on a mobile simulator.

What will be covered during this training:

Architecture of Couchbase Mobile
Understanding Sync Gateway
Data movement to/from Couchbase Lite
Understanding Sync Functions
Setup CouchbaseCloud account
Run Demo Application on simulator

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,092
On SlideShare
0
From Embeds
0
Number of Embeds
280
Actions
Shares
0
Downloads
55
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Online Training - Couchbase Mobile 101

  1. 1. Couchbase*M101:** Mobile*Architecture Jasdeep*Jaitla* Technical)Evangelist email:)jasdeep@couchbase.com twi8er:)@scalabl3
  2. 2. Architecture*of*Couchbase*Mobile
  3. 3. JSON*Anywhere On Mobile Device In Data Center/Cloud In Data Center/Cloud
  4. 4. JSON*Anywhere On Mobile Device In Data Center/Cloud In Data Center/Cloud
  5. 5. JSON*Anywhere On Mobile Device In Data Center/Cloud In Data Center/Cloud
  6. 6. JSON*Anywhere On Mobile Device In Data Center/Cloud In Data Center/Cloud
  7. 7. TradiAonal*Mobile ApplicaAon*Server REST*Services
  8. 8. TradiAonal*Mobile ApplicaAon*Server REST*Services
  9. 9. Construction/ Deconstruction of JSON TradiAonal*Mobile RDBMS Style Local Storage ApplicaAon*Server REST*Services
  10. 10. Construction/ Deconstruction of JSON TradiAonal*Mobile RDBMS Style Local Storage Complex Sync Code ApplicaAon*Server REST*Services Complex Sync Code While Offline or Cannot Use App While Offline
  11. 11. Construction/ Deconstruction of JSON TradiAonal*Mobile RDBMS Style Local Storage Complex Sync Code ApplicaAon*Server REST*Services Complex Sync Code While Offline or Cannot Use App While Offline
  12. 12. Mobile*DBaaS DBaaS REST*Services
  13. 13. Mobile*DBaaS Simple Storage Only DBaaS REST*Services
  14. 14. Mobile*DBaaS Scaling Expensive/Slow Simple Storage Only DBaaS REST*Services
  15. 15. Mobile*DBaaS Scaling Expensive/Slow Simple Storage Only DBaaS REST*Services
  16. 16. Mobile*DBaaS RDBMS Style Local Storage Scaling Expensive/Slow Simple Storage Only DBaaS REST*Services
  17. 17. Mobile*DBaaS RDBMS Style Local Storage Scaling Expensive/Slow Simple Storage Only DBaaS REST*Services Complex Sync Code
  18. 18. JSON*Anywhere*G*Automated*Sync
  19. 19. JSON*Anywhere*G*Automated*Sync
  20. 20. JSON*Anywhere*G*Automated*Sync Synchronization Automated when Connectivity Present
  21. 21. Couchbase*Lite
  22. 22. Couchbase*Lite* The*only* Na3ve*NoSQL* Database*for* Mobile*
  23. 23. Couchbase*Lite The)only)NoSQL)Database)for)Mobile)Devices Couchbase* Lite** iOS* Lite Couchbase* Lite** Android* Features* UltraDlightweight,)secure)JSON)database)) NaIve)support)for)iOS,)Android)and) REST/HTML5) Powerful)conflict)resoluIon) Automated)Sync)
  24. 24. Couchbase*Lite*Features • Use*JSON*in*your*Mobile*App*Data*Tier* • Always*Work*with*Local*Data*on*Device* • Modify*schema*dynamically,*super*flexible* • When*Connected:**Create*New*Data*and*Change*Documents,* they*Sync*AutomaAcally* • When*Not*Connected:*Work*with*solid*local*NoSQL*database* • Powerful*conflict*resoluAon*features
  25. 25. Partner*IntegraAons Adobe*PhoneGap* ! Appcelerator*Titanium* ! Xamarin
  26. 26. PhoneGap)Integra.on) Couchbase*Lite*Plug1in*for*PhoneGap * •  •  •  * Support*for*HTML5*developers* Develop*once*in*JavaScript*and*deploy* on*iOS*&*Android* Available*on*GitHub,*Cordova*Plugin* Registry,*and*coming*soon*to* build.phonegap.com* hHps://github.com/couchbaselabs/Couchbase1Lite1PhoneGap1Plugin* hHp://plugins.cordova.io/#/com.couchbase.lite.phonegap*
  27. 27. Xamarin'Integra,on' Couchbase*Lite*for*Xamarin * •  •  •  Partnered*to*support*C#*community* Available*on*Developer*Center* Includes*sample*applica=on*to*help* developers*get*started*today* h?p://components.xamarin.com/view/couchbaseElite/*
  28. 28. Appcelerator*Integra.on* Couchbase*Lite*Titanium * •  •  Build*rich*na5ve*apps*for*iOS*&* Android*using*JavaScript*SDK* Now*available*on*the*Appcelerator* Marketplace* hEps://github.com/couchbaselabs/couchbaseIliteI5tanium/* hEps://marketplace.appcelerator.com/apps/6706?1396013098*
  29. 29. Couchbase*Sync*Gateway
  30. 30. What*is*the*Sync*Gateway? Couchbase Sync Gateway is a server side program that sits in front of Couchbase Server to manage sync and sync administration • • • • • Sync Operations/Management User Authentication User channel configuration User roles and info (name, email, password) User enable/disable
  31. 31. Sync*Gateway*Overview Sync Gateway Sync REST API Subcomponents Couchbase Smart Client
  32. 32. Subcomponents*of*Sync*Gateway Sync Gateway Authentication Sync REST API Sync Function Channel Change Tracking Conflict Management/ Revisions Couchbase Smart Client
  33. 33. The*Sync*FuncAon Sync Function function(doc,+oldDoc)+{+ ! }
  34. 34. The*Sync*FuncAon Sync Function json doc function(doc,+oldDoc)+{+ ! }
  35. 35. The*Sync*FuncAon Sync Function json doc previous revision, if any function(doc,+oldDoc)+{+ ! }
  36. 36. The*Sync*FuncAon • Defined*in*the*Sync*Gateway*Launch*ConfiguraAon* • Processes*Documents*and*Sync*FuncAons*Calls* • Creates*associaAons*between*Documents,*Channels,*Users* and*Roles* ! • Sync*FuncAons*Calls:* • • • • channel*(channels)** access*(usersGroles,*channels)* role*(users,*roles)* throw({*type:*“message”})
  37. 37. channel() Associate)JSON)Document)with)a)Channel • Channel*Names*are*strings*(i.e.*“food”,*“chatG12939”)* • Associate*this*Document*to*Channel*or*Array*of*Channels* • Overwrites*previous*associaAons,*can*change*channels Sync Function function(doc,+oldDoc)+{+ channel+(doc.channel_name)+ }
  38. 38. channel() Associate)JSON)Document)with)a)Channel • Channel*Names*are*strings*(i.e.*“food”,*“chatG12939”)* • Associate*this*Document*to*Channel*or*Array*of*Channels* • Overwrites*previous*associaAons,*can*change*channels Sync Function function(doc,+oldDoc)+{+ channel+(doc.channel_name)+ } associates this doc with channel
  39. 39. channel() • Channels*organize*what*JSON*Documents*are*synchronized* down*to*which*Users* • Users*are*associated*with*Channels* • Users*are*associated*with*Roles** • Roles*are*associated*with*Channels* • Channels*are*defined*as*JSON*strings*or*array*of*strings*within* the*JSON*Document
  40. 40. channel() Channels*organize*what*JSON*Documents*are* synchronized*down*to*which*Users User*A channels:*food User*B channels:*sports User*C channels:*food,*travel These*Users*Subscribed** to*Content*Channels doc.channels*:*“food” JSON doc.channels*:*[*“food”,*“sports”*] JSON doc.channels*:*[*“sports”,*“travel”*] JSON User*D*creates*Content* with*Channel*associaAon
  41. 41. channel() Channels*organize*what*JSON*Documents*are* synchronized*down*to*which*Users User*A channels:*food User*B channels:*sports User*C channels:*food,*travel These*Users*Subscribed** to*Content*Channels doc.channels*:*“food” JSON doc.channels*:*[*“food”,*“sports”*] JSON doc.channels*:*[*“sports”,*“travel”*] JSON User*D*creates*Content* with*Channel*associaAon
  42. 42. channel() Channels*organize*what*JSON*Documents*are* synchronized*down*to*which*Users User*A channels:*food User*B channels:*sports User*C channels:*food,*travel These*Users*Subscribed** to*Content*Channels doc.channels*:*“food” JSON doc.channels*:*[*“food”,*“sports”*] JSON doc.channels*:*[*“sports”,*“travel”*] JSON User*D*creates*Content* with*Channel*associaAon
  43. 43. channel() Channels*organize*what*JSON*Documents*are* synchronized*down*to*which*Users User*A channels:*food User*B channels:*sports User*C channels:*food,*travel These*Users*Subscribed** to*Content*Channels doc.channels*:*“food” JSON doc.channels*:*[*“food”,*“sports”*] JSON doc.channels*:*[*“sports”,*“travel”*] JSON User*D*creates*Content* with*Channel*associaAon
  44. 44. channel() Channels*organize*what*JSON*Documents*are* synchronized*down*to*which*Users User*A channels:*food User*B channels:*sports User*C channels:*food,*travel These*Users*Subscribed** to*Content*Channels doc.channels*:*“food” JSON doc.channels*:*[*“food”,*“sports”*] JSON doc.channels*:*[*“sports”,*“travel”*] JSON User*D*creates*Content* with*Channel*associaAon
  45. 45. channel() Channels*organize*what*JSON*Documents*are* synchronized*down*to*which*Users User*A channels:*food User*B channels:*sports User*C channels:*food,*travel These*Users*Subscribed** to*Content*Channels doc.channels*:*“food” JSON doc.channels*:*[*“food”,*“sports”*] JSON doc.channels*:*[*“sports”,*“travel”*] JSON User*D*creates*Content* with*Channel*associaAon
  46. 46. channel() Channels*organize*what*JSON*Documents*are* synchronized*down*to*which*Users User*A channels:*food User*B channels:*sports User*C channels:*food,*travel These*Users*Subscribed** to*Content*Channels doc.channels*:*“food” JSON doc.channels*:*[*“food”,*“sports”*] JSON doc.channels*:*[*“sports”,*“travel”*] JSON User*D*creates*Content* with*Channel*associaAon
  47. 47. access() Grants)access)to)channels) • Associate*a*User,*or*Array*of*Users*to*one*or*more*Channels* • Associate*a*Role*(group*of*Users)*to*one*or*more*Channels Sync Function function(doc,+oldDoc)+{+ access+(doc.friends,+doc.channels)+ }
  48. 48. access() Grants)access)to)channels) • Associate*a*User,*or*Array*of*Users*to*one*or*more*Channels* • Associate*a*Role*(group*of*Users)*to*one*or*more*Channels Sync Function function(doc,+oldDoc)+{+ access+(doc.friends,+doc.channels)+ } associates users/roles with channel(s)
  49. 49. role() grants)users)a)role • Associate*a*User,*or*Array*of*Users*to*one*or*more*Roles* • Roles*can*give*enAre*groups*of*Users*access*to*Channels Sync Function function(doc,+oldDoc)+{+ role+(doc.friends,+roles)+ }
  50. 50. role() grants)users)a)role • Associate*a*User,*or*Array*of*Users*to*one*or*more*Roles* • Roles*can*give*enAre*groups*of*Users*access*to*Channels Sync Function function(doc,+oldDoc)+{+ role+(doc.friends,+roles)+ } associates user(s) with role(s)
  51. 51. throw() validate)documents,)prevent)syncing/modificaIons • ValidaAon*of*document*data*and*associaAons* • ValidaAon*of*authenAcaAon Sync Function function(doc,+oldDoc)+{+ throw+({+type:+“message”})+ }
  52. 52. throw() validate)documents,)prevent)syncing/modificaIons • ValidaAon*of*document*data*and*associaAons* • ValidaAon*of*authenAcaAon Sync Function function(doc,+oldDoc)+{+ throw+({+type:+“message”})+ } invalidates this document
  53. 53. Collaborate*with*Channels • For*each*document,*you*specify*a*set*of*channels* it*belongs*to* • For*each*user*or*device,*you*control*which* channels*they*can*access* • Replicate*only*a*subset*of*documents*down*to*the* device* • UserDdefined)filter)funcIons)) • Simply)lets)you)know)whether)a)document)should)be)replicated) • And*you*can*authenAcate*users*with*Facebook* and*Persona
  54. 54. DEMO
  55. 55. Q*&*A

×