$30 off During Our Annual Pro Sale. View Details »

Couchbase Lite iOS Geo

Couchbase Lite iOS Geo

Chris Anderson

September 12, 2014
Tweet

More Decks by Chris Anderson

Other Decks in Programming

Transcript

  1. Geo Queries in Couchbase Mobile

    Implementing and using Geographic indexes


    Chris Anderson, Mobile Architect


    View Slide

  2. Agenda
    Couchbase Mobile
    Geo App Demo
    Geo Index Implementation
    Q/A
    2

    View Slide

  3. 3
    Couchbase  Lite
     
    On-­‐device,  lightweight,  native  
    embedded  JSON  database
    Sync  Gateway
     
    Synchronize  on-­‐device  
    Couchbase  Lite  with  Couchbase  
    Server  in  the  cloud
    Couchbase  Server
     
    High  performance,  scalable,  
    always-­‐on  JSON  database  in  
    the  cloud


    Couchbase Mobile

    View Slide

  4. 4
    Couchbase  Lite
    Couchbase Lite
    Full Featured
    JSON
    Native
    Lightweight
    Secure
    Beta

    View Slide

  5. Conflict Resolution
    5
    Johnny
    (555)123-4567
    Johnny Smith
    [email protected]
    123 Main Street
    Anywhere, USA
    (555)123-4567
    Johnny Smith
    123 Main Street
    Anywhere, USA
    (555)123-4567
    John A. Smith
    [email protected]
    123 Main Street
    Anywhere, USA
    (555)123-4567
    John A. Smith
    [email protected]
    123 Main Street
    Anywhere, USA
    (555)123-4567
    Johnny Smith
    (555)123-4567
    Jon A. Smith
    [email protected]
    123 Main Street
    Anywhere, USA
    (555)123-4567
    John A. Smith
    [email protected]
    123 Main Street
    Anywhere, USA
    (555)123-4567
    CONFLICT ACTIVE

    View Slide

  6. 6
    Sync  Gateway
    Sync Gateway
    Replication
    Access Control
    Filtering
    Validation

    View Slide

  7. Channels
    7
    Sports San  Francisco
    Nature
    Admin

    View Slide

  8. Replication
    Pure  
    Peer-­‐to-­‐Peer
    Peer-­‐to-­‐Peer Scale  Out
    8

    View Slide

  9. Access Control, Filtering, and Validation
    9
    Pluggable Authentication
    Javascript sync function runs on all mutations.
    Access/Filtering
    – channel(…): Routes the document to the named channel
    – access(…): Grants access to a channel to a specified user, list of users, or a role
    – role(…): Grants a user a role
    Validation
    – throw(…): Prevents a document mutation from persisting
    – requireUser/Role/Access(…): Validates the user, their role assignments, or their
    access privileges.

    View Slide

  10. Sync Function
    10
    function (doc, oldDoc) {
    if (doc.published) {
    channel ("public");
    }
    access (”joe", ”public");
    !
    role (”joe", "role:admin");
    !
    throw ({forbidden : "read only!"})
    !
    requireUser(doc.owner);
    requireRole("admin");
    requireAccess(”public");
    }

    View Slide

  11. 11
    Couchbase  Server
    Couchbase Server
    JSON
    Highly Scalable
    High Performance
    Always On

    View Slide

  12. Customers

    View Slide

  13. Infinite Campus
    Education  /  Social  Interaction  
    ▪ Selectively  push  out  learning  modules  /  
    multimedia  lessons  to  individual  students  
    ▪ Teachers  and  students  use  custom  mobile  
    chat  apps  for  real-­‐time  Q&A  during  
    lectures  
    ▪ Homework  assignments  can  be  completed  
    offline  anywhere
    “We needed to provide an educational experience as engaging as the apps students love to use everyday. The ability to
    work online/offline and seamlessly sync across devices and between users was critical to delivering the experience they
    need for both in the classroom, and off campus. We investigated the market for an ultra-lightweight NoSQL mobile
    database with easy sync and Couchbase was the only choice.”
    Mike Lamb, Principal Software Engineer, Infinite Campus

    View Slide

  14. Picsolve
    Embedded    
    ▪ Image  capture  of  roller  coaster  
    riders  to  local  database  in  multiple  
    theme  park  locations  
    ▪ Machine  to  machine  
    communication  example  
    ▪ Unreliable  network  connectivity  
    required  offline  capture  /  later  
    sync  to  centralized  management  
    system

    View Slide

  15. Microsoft
    Peer-­‐to-­‐Peer  
    ▪ What  does  it  mean  to  make  the  
    web  truly  peer-­‐to-­‐peer?  
    ▪ Data  stored  on  the  edge  
    ▪ Enable  applications  that  can  live  
    on  the  edge  of  the  network

    View Slide

  16. Demo App

    View Slide

  17. Couchbase Lite Setup
    Setup  Steps  
    ▪ Open  database  
    ▪ Configure  sync  
    ▪ Install  index  definitions

    View Slide

  18. Import Photos
    Loading  Photos  
    ▪ Enumerate  assets  
    ▪ Save  JSON  document  
    ▪ Attach  image  thumbnail

    View Slide

  19. Live Query for Map Annotations
    Rendering  Points  
    ▪ Create  LiveQuery  
    ▪ Observe  Results  
    ▪ Update  Map  Annotations

    View Slide

  20. Update Query on Region Change
    Bounding  Box  
    ▪ Observe  Region  Changes  
    ▪ BBox  from  MapRect  
    ▪ Refresh  Live  Query

    View Slide

  21. Implementation

    View Slide

  22. Get Started
    developer.couchbase.com

    View Slide

  23. View Slide

  24. Q&A

    View Slide