O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Mobile workshop: Data Orchestration: Couchbase Connect 2015

779 visualizações

Publicada em

This daylong workshop will feature a combination of lecture and hands-on lab training on Couchbase Mobile, the embeddable JSON database with built-in sync for Android, iOS, Xamarin and Unity. During this workshop, we will take Android and iOS developers through everything you need to know to get started working with Couchbase Mobile.

Publicada em: Tecnologia
  • Seja o primeiro a comentar

  • Seja a primeira pessoa a gostar disto

Mobile workshop: Data Orchestration: Couchbase Connect 2015

  1. 1. COUCHBASE  MOBILE   DATA  ORCHESTRATION
  2. 2. 2
  3. 3. ©2014  Couchbase  Inc. 3 Data Routing DataData
  4. 4. ©2014  Couchbase  Inc. 4 Data Routing Data Data Data
  5. 5. ©2014  Couchbase  Inc. 5 Data Routing Data Data DataData
  6. 6. ©2014  Couchbase  Inc. 6 Data Routing Data D ata Data DataData
  7. 7. ©2014  Couchbase  Inc. 7 Data Routing Data D ata Data Data DataData
  8. 8. ©2014  Couchbase  Inc. 8 Data Routing Data Data Data Data DataData
  9. 9. ©2014  Couchbase  Inc. Data  Model   9
  10. 10. Sync  Function
  11. 11. ©2014  Couchbase  Inc. Sync  Gateway ▪ channel(name)   ▪ access(username,  channelname)   ▪ role(username,  rolename)   ▪ requireUser(username)   ▪ require(rolename)   ▪ requireAccess(channels) 11
  12. 12. function(doc, oldDoc) { if (doc.type == "task") { channel("list-" + doc.list_id); } else if (doc.type == "list") { channel("list-" + doc._id); access(doc.owner, "list-" + doc._id); access(doc.members, "list-" + doc._id); } else if (doc.type == "profile") { access(doc._id, "profiles"); } } { "_id": "ben@gmail.com", "type": "profile" } Sync  Gateway list-123 list-453 profiles Sync Function
  13. 13. function(doc, oldDoc) { if (doc.type == "task") { channel("list-" + doc.list_id); } else if (doc.type == "list") { channel("list-" + doc._id); access(doc.owner, "list-" + doc._id); access(doc.members, "list-" + doc._id); } else if (doc.type == "profile") { access(doc._id, "profiles"); } } { "_id": "123" "type": "list", "title": "Home List", "owner": "ben@gmail.com", "members": [ "ali@gmail.com", "joe@yahoo.com" ] } Sync  Gateway list-123 list-453 profiles Sync Function
  14. 14. function(doc, oldDoc) { if (doc.type == "task") { channel("list-" + doc.list_id); } else if (doc.type == "list") { channel("list-" + doc._id); access(doc.owner, "list-" + doc._id); access(doc.members, "list-" + doc._id); } else if (doc.type == "profile") { access(doc._id, "profiles"); } } { "_id": "999" "type": "task", "list_id": "123", "title": "Buy some hummus" } Sync  Gateway list-123 list-453 profiles Sync Function
  15. 15. function(doc, oldDoc) { if (doc.type == "task") { channel("list-" + doc.list_id); } else if (doc.type == "list") { channel("list-" + doc._id); access(doc.owner, "list-" + doc._id); access(doc.members, "list-" + doc._id); } else if (doc.type == "profile") { access(doc._id, "profiles"); } } { "_id": "123" "type": "list", "title": "Home List", "owner": "johnny@apple.com", "members": [ "ali@gmail.com", "joe@yahoo.com" ] } Sync  Gateway list-123 list-453 profiles Sync Function
  16. 16. ©2014  Couchbase  Inc. Sync  Gateway ▪ Executed  on  every  document   ▪ Written  in  JavaScript   ▪ Pure  function   ▪ Can  be  changed  at  any  time 16
  17. 17. ©2014  Couchbase  Inc. User  Context { "authentication_handlers": [ "default", "cookie" ], "ok": true, "userCtx": { "channels": { "list-02883035-5a2f-4862-b441-ea46254afda3": 60130, "list-e6941937-6fa3-4a56-973a-2c0f992fbea4": 129727, "list-f35902a0-8333-43d0-b383-6ee46efc2dd0": 129719, "profiles": 59264 }, "name": "james.nocentini2@gmail.com" } } 17
  18. 18. ©2014  Couchbase  Inc. Replications facebookAuthenticator = AuthenticatorFactory.createFacebookAuthenticator(accessToken); pull = db.createPullReplication(SYNC_URL); pull.setAuthenticator(facebookAuthenticator); pullReplication.setContinuous(true); push = db.createPushReplication(SYNC_URL); push.setAuthenticator(facebookAuthenticator); pushReplication.setContinuous(true); pull.start(); push.start(); 18
  19. 19. ©2014  Couchbase  Inc. Replications db.createPullReplication(url); // replicator List<String> channels = new ArrayList<String>(); channels.add("list-UHFIEJOI-FNOEWF-ODIDIW"); pull.setChannels(channels); // only this channel 19

×