SlideShare a Scribd company logo
44




Peter Friese / Stefan Reichert, Zühlke Engineering


CouchDB mobile
From Couch To 5k in 1 Hour
Peter Friese




  @peterfriese
  peter.friese@zuehlke.com
  xing.to/peter
  http://peterfriese.de
Stefan Reichert




             @stefanreichert

stefan.reichert@zuehlke.com

       xing.to/stefanreichert

http://blog.wickedshell.net/
What we will cover today


 1   What is CouchDB?


 2   Serious amount of demos!


 3   Couch25K - A Runner’s App
What is CouchDB?

                   1
CouchDB is...
CouchDB is...
          A NoSQL Database.
CouchDB is...
            Document-Oriented.
   {
   !   "name": "Peter",
   !   "company": "Zühlke Engineering",
   !   "email": "peter.friese@zuehlke.com",
   !   "languages": [
   !   ! "Objective-C",
   !   ! "Java",
   !   ! "C#",
   !   ! "JavaScript"
   !   ]
   }
CouchDB is...
            Schema-Free.

                Put anything
                you like into
                your CouchDB.
                Really.
CouchDB is...
          Erlang-Powered.
CouchDB is...
                 RESTful.

 GET
 PUT            Fully embraces
 POST           HTTP verbs
 DELETE
CouchDB uses...




http://research.google.com/archive/mapreduce.html
                                                    Map/Reduce (JavaScript).
CouchDB uses...

   Map/Reduce (JavaScript).

Input
{"ip":   "212.23.45.12","traffic": “18278", date: “2012-03-11”},
{"ip":   "74.12.345.1","traffic": “345", date: “2012-03-11”},
{"ip":   "212.23.45.12","traffic": “112244", date: “2012-03-12”},
{"ip":   "212.23.45.12","traffic": “8657", date: “2012-03-13”},
{"ip":   "74.12.345.12","traffic": “12", date: “2012-03-12”},
{"ip":   "10.122.111.22","traffic": “122222", date: “2012-03-11”}
CouchDB uses...

   Map/Reduce (JavaScript).

Mapper                   Input for Reducer
212.23.45.12    18278    212.23.45.12    18278
74.12.345.1     345      212.23.45.12    112244
212.23.45.12    112244   212.23.45.12    8657
212.23.45.12    8657
74.12.345.1     12       74.12.345.1     12
10.122.111.22   122222   74.12.345.1     345

                         10.122.111.22   122222
CouchDB uses...

   Map/Reduce (JavaScript).
Input for Reducer After Reduce
212.23.45.12    18278    212.23.45.12    139179
212.23.45.12    112244
212.23.45.12    8657

74.12.345.1     12       74.12.345.1     357
74.12.345.1     345

10.122.111.22   122222   10.122.111.22   122222
CouchDB features...
       Robust Replication.
CouchDB features...
          Robust Replication.
                     Laptop


  Phone


                     Server
Demos

        2
Calling Home

  curl localhost:5984


{"couchdb":"Welcome","version":"1.1.0"}
Creating a New DB

 curl -X PUT localhost:5984/helloworld



                         {"ok":true}
Deleting a Database
 curl -X DELETE http://
 localhost:5984/helloworld


                             {"ok":true}
Creating a New Document
 curl
   -X POST
   -H "Content-Type: application/json"
   localhost:5984/helloworld
   -d @peter.json


 {"ok":true,"id":"f8e42aaa4bc77124c28
 6be13f000054e","rev":"1-4dc37117e0da
 26d9c50dc92d4cbb04cc"}
Curious? GET Your Document!
 curl http://localhost:5984/helloworld/
 f8e42aaa4bc77124c286be13f000054e



 {
     "_id": "f8e42aaa4bc77124c286be13f000054e",
     "_rev": "1-4dc37117e0da26d9c50dc92d4cbb04cc",
     "name": "Peter",
     "company": "Zühlke Engineering",
     "email": "peter.friese@zuehlke.com"
 }
Anatomy of a Document
{
    "_id": "f8e42aaa4bc77124c286be13f000054e",
    "_rev": "1-4dc37117e0da26d9c50dc92d4cbb04cc",
    "name": "Peter",
    "company": "Zühlke Engineering",
    "email": "peter.friese@zuehlke.com"
}

           UUID - very
          unique identifier
Anatomy of a Document
 {
     "_id": "f8e42aaa4bc77124c286be13f000054e",
     "_rev": "1-4dc37117e0da26d9c50dc92d4cbb04cc",
     "name": "Peter",
     "company": "Zühlke Engineering",
     "email": "peter.friese@zuehlke.com"
 }


revision revision              hash (body,
number counter                 attachment,
                              _deleted flag)
Welcome to Futon!


         Admin interface for CouchDB
         CRUD for Documents
         Manage Views
         Manage Replication
Couch25K - A Runner’s App

                     3
Basic Idea




         2-way       2-way

 Phone       IrisCouch       Phone
CouchDB Mobile




                     n e ?
                P h o
        o u r
     n y
   o
CouchDB Mobile

Your app   CouchCocoa lib     Ektorp lib   Your app




           CouchDB          CouchDB
CouchDB Mobile
 Your app   CouchCocoa lib    Ektorp lib   Your app




             TouchDB lib     TouchDB lib




             SQlite          SQlite
CouchDB Mobile


   “TouchDB is a lightweight CouchDB-
   compatible database engine suitable
   for embedding into mobile or desktop
   apps. Think of it this way: If
   CouchDB is MySQL, then TouchDB
   is SQLite.”  - Jens Alfke, Couchbase
                Labs
Start a Local Couch
 CouchTouchDBServer *server =
  [CouchTouchDBServer sharedInstance];
 NSAssert(!server.error,
  @"Error initializing TouchDB server: %@",
  server.error);

 self.database = [server
  databaseNamed:@"couch25k"];

 NSError *error;
 if (! [self.database ensureCreated:&error]) {
   // raise error
   self.connected = false;
 }
Start a Local Couch
try {
  TDServer touchDBServer = new TDServer(filesDir);
!
  HttpClient httpClient = new
   TouchDBHttpClient(touchDBServer);
  CouchDbInstance couchDBInstance =
   new StdCouchDbInstance(httpClient);
!
  CouchDbConnector couchDBConnector =
   couchDBInstance.createConnector(COUCH25K_DB,true);
! ...
} catch (IOException e) {
! Log.e(TAG, "Error starting TDServer", e);
}
Trackpoints



  {
      "run": "run-peterfriese-19",
      "user": "peterfriese",
      "lon": "9.990512659959458",
      "time": "2012-03-24 07:39:27 +0000",
      "lat": "53.73176022303823"
  }
Saving a Trackpoint
NSDictionary *trackpointProperties =
 [NSDictionary dictionaryWithObjectsAndKeys: (...)

CouchDocument *trackpointDocument =
 [database untitledDocument];

RESTOperation* op = [trackpointDocument
 putProperties:trackpointProperties];

[op onCompletion: ^{
 if (op.error)
   NSLog(@"Couldn't save the new item");
 }];
[op start];
Saving a Trackpoint
Ektorp: JPA for CouchDB
  public class TrackPoint extends CouchDbDocument


Repository Support
  public class TrackPointRepository extends
  ! CouchDbRepositorySupport<TrackPoint>


... so saving a TrackPoint is pretty easy
  trackPointRepository.add(trackPoint);
Sync with the Server


NSURL *url = [NSURL
 URLWithString:
   @"http://peterfriese.iriscouch.com/couch25k"];

[self.database replicateWithURL:url exclusively: YES];
Sync with the Server
Pull from Server
 ReplicationCommand commandPull = new
  ReplicationCommand.Builder()
    .source(COUCH25K_REMOTE_DB)
    .target(COUCH25K_DB)
    .continuous(true).build();

 try {
   couchDBInstance.replicate(commandPull);
 } catch (Exception exception) {
   Log.e(TAG, exception.getMessage(), exception);
 }
Sync with the Server
Push to Server
 ReplicationCommand commandPush = new
  ReplicationCommand.Builder()
    .source(COUCH25K_DB)
    .target(COUCH25K_REMOTE_DB)
    .continuous(true).build();

 try {
   couchDBInstance.replicate(commandPush);
 } catch (Exception exception) {
   Log.e(TAG, exception.getMessage(), exception);
 }
Demo
Display List of Runs (JavaScript)

     Map                 Reduce
                       function(keys, values)
 function(doc) {
                       {
   emit(doc.run, 1);
                         return sum(values);
 }
                       }


  run-1    1
  run-1    1
                       run-1     3
  run-1    1
                       run-2     2
  run-2    1
  run-2    1
Display List of Runs (Obj-C)

Map
[design defineViewNamed: @"runs" mapBlock: MAPBLOCK({
 id run = [doc objectForKey:@"run"];
 if (run) emit(run, nil);
})


Reduce
reduceBlock:REDUCEBLOCK({
 return [NSNumber numberWithInt:values.count];
})
Display List of Runs (Java)

Map
new TDViewMapBlock() {
  public void map(Map<String, Object> doc,
    TDViewMapEmitBlock emitter) {
    if (doc.containsKey("run")) {
      emitter.emit(doc.get("run"), doc.get("_id"));
    }
  }
}
Display List of Runs (Java)
(Re-) reduce
new TDViewReduceBlock() {
 public Object reduce(List<Object> keys, List<Object>
   values, boolean rereduce) {
   if (rereduce) {
     int sum = 0;
     for (Object object : values) {
       sum += (Integer) object;
     }
     return sum;
   }
   return values.size();
 }
};
Filtering
        Peter           Stefan

            Filter by name




    sync 2-way        sync 2-way

Phone           IrisCouch    Phone 2
Filtering
CouchDB
by_user:

 function(doc, rq) {
   if(doc.user == rq.query.username) {
     return true;
   }
   return false;
 }
Filtering
NSArray *replications =
 [self.database replicateWithURL:url exclusively: YES];

CouchPersistentReplication *from =
 [replications objectAtIndex:0];
from.continuous = YES;

from.filter = @"couch25k/by_user";
NSDictionary *filterParams = [NSDictionary
 dictionaryWithObjectsAndKeys:
   @"peterfriese", @"username", nil];
from.query_params = filterParams;
Filtering
Map<String, Object> queryParams =
 new HashMap<String, Object>();
queryParams.put("username", "stefanreichert");

ReplicationCommand commandPull = new
  ReplicationCommand.Builder()
   .source(COUCH25K_REMOTE_DB)
   .target(COUCH25K_DB).continuous(true)
   .filter("by_user")
   .queryParams(queryParams).build();
try {
! couchDBInstance.replicate(commandPull);
} catch (Exception e) {
! Log.e(TAG, exception.getMessage(), e);
}
Maps, please!
Query Trackpoints by Run
Map
mapBlock: MAPBLOCK({
 NSString *run = (NSString *)[doc objectForKey:@"run"];
 id time = [doc objectForKey:@"time"];
 NSMutableArray *key = [[NSMutableArray alloc] init];
 [key addObject:run];
 [key addObject:time];
 emit(key, doc);})

[run-peter-1,   2012-03-23   10:10]   {lat:...,   lon:...}
[run-peter-1,   2012-03-23   10:11]   {lat:...,   lon:...}
[run-peter-2,   2012-03-26   20:05]   {lat:...,   lon:...}
[run-peter-2,   2012-03-26   20:06]   {lat:...,   lon:...}
[run-peter-2,   2012-03-26   10:07]   {lat:...,   lon:...}
Query Trackpoints by Run
Query
CouchQuery *query = [[self.database
 designDocumentWithName: @"couch25k"]
 queryViewNamed: @"waypoints_by_run"];

CouchLiveQuery *livequery = [query asLiveQuery];

[livequery setStartKey:
 [NSArray arrayWithObjects:self.runKey, nil]];

[query setEndKey:
 [NSArray arrayWithObjects:self.runKey, @"ZZZ", nil]];
Query Trackpoints by Run
Map
new TDViewMapBlock() {
  public void map(Map<String, Object> document,
   TDViewMapEmitBlock emitter) {
   if (document.containsKey("run")) {
     document.get("run"), document.get("_id"));
   }
}
Query Trackpoints by Run
Query
ViewQuery viewQuery = new
 ViewQuery().designDocId("_design/TrackPoint")
   .viewName("trackpoint_by_run")
   .key(runId);
ViewResult result = db.queryView(viewQuery);
List<TrackPoint> trackPoints = new
 ArrayList<TrackPoint>();

for (Row row : result.getRows()) {
  TrackPoint trackPoint = get(row.getValue());
  trackPoints.add(trackPoint);
}
return trackPoints;
And finally...




        http://josephta.me/about-joseph-tame/
... a Tribute to Steve Jobs
                                  GPX
                                of J   cou
                                            rtes
                                     ose         y
                                         ph
                                  - T       Tam
                                      han        e
                                          ks!




         http://bit.ly/HbDRod
Relax!




 44
Thanks!
Peter Friese
Principal Consultant
                                                      rt   @peterfr
Zühlke Engineering GmbH                 @stef anreiche             iese
Am Sandtorkai 66
20457 Hamburg                        Availa
                                            ble fo
+49 151 108 604 72                   discu         r con
                                           ssing          sultin
                                                  all th         g,
                   rt
           Reiche Engineer          mobil                ings
    Stefan
            Software
                                          e and
    Senior                      H   frost
               nginee
                      rin g Gmb           y beve
             E
     Zühlke torkai 66                            rages
             nd
      Am Sa           rg
              Hambu
      20457
                           6
                 961 43 3
       + 49 173


                                                           PS: we’re hiring...
Ad

More Related Content

What's hot (20)

MongoDB: tips, trick and hacks
MongoDB: tips, trick and hacksMongoDB: tips, trick and hacks
MongoDB: tips, trick and hacks
Scott Hernandez
 
Elk stack
Elk stackElk stack
Elk stack
Jilles van Gurp
 
Logstash-Elasticsearch-Kibana
Logstash-Elasticsearch-KibanaLogstash-Elasticsearch-Kibana
Logstash-Elasticsearch-Kibana
dknx01
 
OrientDB
OrientDBOrientDB
OrientDB
aemadrid
 
Realtime Analytics Using MongoDB, Python, Gevent, and ZeroMQ
Realtime Analytics Using MongoDB, Python, Gevent, and ZeroMQRealtime Analytics Using MongoDB, Python, Gevent, and ZeroMQ
Realtime Analytics Using MongoDB, Python, Gevent, and ZeroMQ
Rick Copeland
 
MySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELKMySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELK
YoungHeon (Roy) Kim
 
Elk stack @inbot
Elk stack @inbotElk stack @inbot
Elk stack @inbot
Jilles van Gurp
 
Side by Side with Elasticsearch and Solr
Side by Side with Elasticsearch and SolrSide by Side with Elasticsearch and Solr
Side by Side with Elasticsearch and Solr
Sematext Group, Inc.
 
Logstash: Get to know your logs
Logstash: Get to know your logsLogstash: Get to know your logs
Logstash: Get to know your logs
SmartLogic
 
mongoDB Performance
mongoDB PerformancemongoDB Performance
mongoDB Performance
Moshe Kaplan
 
GCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow IntroductionGCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow Introduction
Simon Su
 
wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?wtf is in Java/JDK/wtf7?
wtf is in Java/JDK/wtf7?
Scott Leberknight
 
Debugging and Testing ES Systems
Debugging and Testing ES SystemsDebugging and Testing ES Systems
Debugging and Testing ES Systems
Chris Birchall
 
Rapid, Scalable Web Development with MongoDB, Ming, and Python
Rapid, Scalable Web Development with MongoDB, Ming, and PythonRapid, Scalable Web Development with MongoDB, Ming, and Python
Rapid, Scalable Web Development with MongoDB, Ming, and Python
Rick Copeland
 
Elastic Search
Elastic SearchElastic Search
Elastic Search
NexThoughts Technologies
 
아파트 정보를 이용한 ELK stack 활용 - 오근문
아파트 정보를 이용한 ELK stack 활용 - 오근문아파트 정보를 이용한 ELK stack 활용 - 오근문
아파트 정보를 이용한 ELK stack 활용 - 오근문
NAVER D2
 
Building .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase LiteBuilding .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase Lite
gramana
 
ElasticSearch
ElasticSearchElasticSearch
ElasticSearch
Luiz Rocha
 
Unqlite
UnqliteUnqlite
Unqlite
Paul Myeongchan Kim
 
LogStash in action
LogStash in actionLogStash in action
LogStash in action
Manuj Aggarwal
 
MongoDB: tips, trick and hacks
MongoDB: tips, trick and hacksMongoDB: tips, trick and hacks
MongoDB: tips, trick and hacks
Scott Hernandez
 
Logstash-Elasticsearch-Kibana
Logstash-Elasticsearch-KibanaLogstash-Elasticsearch-Kibana
Logstash-Elasticsearch-Kibana
dknx01
 
Realtime Analytics Using MongoDB, Python, Gevent, and ZeroMQ
Realtime Analytics Using MongoDB, Python, Gevent, and ZeroMQRealtime Analytics Using MongoDB, Python, Gevent, and ZeroMQ
Realtime Analytics Using MongoDB, Python, Gevent, and ZeroMQ
Rick Copeland
 
MySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELKMySQL Slow Query log Monitoring using Beats & ELK
MySQL Slow Query log Monitoring using Beats & ELK
YoungHeon (Roy) Kim
 
Side by Side with Elasticsearch and Solr
Side by Side with Elasticsearch and SolrSide by Side with Elasticsearch and Solr
Side by Side with Elasticsearch and Solr
Sematext Group, Inc.
 
Logstash: Get to know your logs
Logstash: Get to know your logsLogstash: Get to know your logs
Logstash: Get to know your logs
SmartLogic
 
mongoDB Performance
mongoDB PerformancemongoDB Performance
mongoDB Performance
Moshe Kaplan
 
GCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow IntroductionGCPUG meetup 201610 - Dataflow Introduction
GCPUG meetup 201610 - Dataflow Introduction
Simon Su
 
Debugging and Testing ES Systems
Debugging and Testing ES SystemsDebugging and Testing ES Systems
Debugging and Testing ES Systems
Chris Birchall
 
Rapid, Scalable Web Development with MongoDB, Ming, and Python
Rapid, Scalable Web Development with MongoDB, Ming, and PythonRapid, Scalable Web Development with MongoDB, Ming, and Python
Rapid, Scalable Web Development with MongoDB, Ming, and Python
Rick Copeland
 
아파트 정보를 이용한 ELK stack 활용 - 오근문
아파트 정보를 이용한 ELK stack 활용 - 오근문아파트 정보를 이용한 ELK stack 활용 - 오근문
아파트 정보를 이용한 ELK stack 활용 - 오근문
NAVER D2
 
Building .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase LiteBuilding .NET Apps using Couchbase Lite
Building .NET Apps using Couchbase Lite
gramana
 

Similar to CouchDB Mobile - From Couch to 5K in 1 Hour (20)

OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
Bradley Holt
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platforms
Ayush Sharma
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
Dongmin Yu
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
Sven Haiges
 
Couchdb: No SQL? No driver? No problem
Couchdb: No SQL? No driver? No problemCouchdb: No SQL? No driver? No problem
Couchdb: No SQL? No driver? No problem
delagoya
 
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Luigi Dell'Aquila
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
PiXeL16
 
Introduction tomongodb
Introduction tomongodbIntroduction tomongodb
Introduction tomongodb
Lee Theobald
 
Advanced CouchDB Rotterdam.rb July 2010
Advanced CouchDB Rotterdam.rb July 2010Advanced CouchDB Rotterdam.rb July 2010
Advanced CouchDB Rotterdam.rb July 2010
Sander van de Graaf
 
Barcelona MUG MongoDB + Hadoop Presentation
Barcelona MUG MongoDB + Hadoop PresentationBarcelona MUG MongoDB + Hadoop Presentation
Barcelona MUG MongoDB + Hadoop Presentation
Norberto Leite
 
TopicMapReduceComet log analysis by using splunk
TopicMapReduceComet log analysis by using splunkTopicMapReduceComet log analysis by using splunk
TopicMapReduceComet log analysis by using splunk
akashkale0756
 
Infrastructure-as-code: bridging the gap between Devs and Ops
Infrastructure-as-code: bridging the gap between Devs and OpsInfrastructure-as-code: bridging the gap between Devs and Ops
Infrastructure-as-code: bridging the gap between Devs and Ops
Mykyta Protsenko
 
NoSQL - An introduction to CouchDB
NoSQL - An introduction to CouchDBNoSQL - An introduction to CouchDB
NoSQL - An introduction to CouchDB
Jonathan Weiss
 
Apache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux FestApache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux Fest
Myles Braithwaite
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
NAVER D2
 
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache KafkaSolutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Guido Schmutz
 
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
confluent
 
Doctrine and NoSQL
Doctrine and NoSQLDoctrine and NoSQL
Doctrine and NoSQL
Benjamin Eberlei
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
Siarzh Miadzvedzeu
 
Блохин Леонид - "Mist, как часть Hydrosphere"
Блохин Леонид - "Mist, как часть Hydrosphere"Блохин Леонид - "Mist, как часть Hydrosphere"
Блохин Леонид - "Mist, как часть Hydrosphere"
Provectus
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
Bradley Holt
 
Flask and Angular: An approach to build robust platforms
Flask and Angular:  An approach to build robust platformsFlask and Angular:  An approach to build robust platforms
Flask and Angular: An approach to build robust platforms
Ayush Sharma
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
Dongmin Yu
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
Sven Haiges
 
Couchdb: No SQL? No driver? No problem
Couchdb: No SQL? No driver? No problemCouchdb: No SQL? No driver? No problem
Couchdb: No SQL? No driver? No problem
delagoya
 
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Geospatial Graphs made easy with OrientDB - Codemotion Warsaw 2016
Luigi Dell'Aquila
 
REST with Eve and Python
REST with Eve and PythonREST with Eve and Python
REST with Eve and Python
PiXeL16
 
Introduction tomongodb
Introduction tomongodbIntroduction tomongodb
Introduction tomongodb
Lee Theobald
 
Advanced CouchDB Rotterdam.rb July 2010
Advanced CouchDB Rotterdam.rb July 2010Advanced CouchDB Rotterdam.rb July 2010
Advanced CouchDB Rotterdam.rb July 2010
Sander van de Graaf
 
Barcelona MUG MongoDB + Hadoop Presentation
Barcelona MUG MongoDB + Hadoop PresentationBarcelona MUG MongoDB + Hadoop Presentation
Barcelona MUG MongoDB + Hadoop Presentation
Norberto Leite
 
TopicMapReduceComet log analysis by using splunk
TopicMapReduceComet log analysis by using splunkTopicMapReduceComet log analysis by using splunk
TopicMapReduceComet log analysis by using splunk
akashkale0756
 
Infrastructure-as-code: bridging the gap between Devs and Ops
Infrastructure-as-code: bridging the gap between Devs and OpsInfrastructure-as-code: bridging the gap between Devs and Ops
Infrastructure-as-code: bridging the gap between Devs and Ops
Mykyta Protsenko
 
NoSQL - An introduction to CouchDB
NoSQL - An introduction to CouchDBNoSQL - An introduction to CouchDB
NoSQL - An introduction to CouchDB
Jonathan Weiss
 
Apache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux FestApache CouchDB talk at Ontario GNU Linux Fest
Apache CouchDB talk at Ontario GNU Linux Fest
Myles Braithwaite
 
[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기[245] presto 내부구조 파헤치기
[245] presto 내부구조 파헤치기
NAVER D2
 
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache KafkaSolutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Solutions for bi-directional Integration between Oracle RDMBS & Apache Kafka
Guido Schmutz
 
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
Solutions for bi-directional integration between Oracle RDBMS and Apache Kafk...
confluent
 
Блохин Леонид - "Mist, как часть Hydrosphere"
Блохин Леонид - "Mist, как часть Hydrosphere"Блохин Леонид - "Mist, как часть Hydrosphere"
Блохин Леонид - "Mist, как часть Hydrosphere"
Provectus
 
Ad

More from Peter Friese (20)

Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI Components
Peter Friese
 
Firebase & SwiftUI Workshop
Firebase & SwiftUI WorkshopFirebase & SwiftUI Workshop
Firebase & SwiftUI Workshop
Peter Friese
 
Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI Components
Peter Friese
 
Firebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroesFirebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroes
Peter Friese
 
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
Peter Friese
 
async/await in Swift
async/await in Swiftasync/await in Swift
async/await in Swift
Peter Friese
 
Firebase for Apple Developers
Firebase for Apple DevelopersFirebase for Apple Developers
Firebase for Apple Developers
Peter Friese
 
Building Apps with SwiftUI and Firebase
Building Apps with SwiftUI and FirebaseBuilding Apps with SwiftUI and Firebase
Building Apps with SwiftUI and Firebase
Peter Friese
 
Rapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebaseRapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and Firebase
Peter Friese
 
Rapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebaseRapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and Firebase
Peter Friese
 
6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase Auth6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase Auth
Peter Friese
 
Five Things You Didn't Know About Firebase Auth
Five Things You Didn't Know About Firebase AuthFive Things You Didn't Know About Firebase Auth
Five Things You Didn't Know About Firebase Auth
Peter Friese
 
Building High-Quality Apps for Google Assistant
Building High-Quality Apps for Google AssistantBuilding High-Quality Apps for Google Assistant
Building High-Quality Apps for Google Assistant
Peter Friese
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google
Peter Friese
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on GoogleBuilding Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google
Peter Friese
 
What's new in Android Wear 2.0
What's new in Android Wear 2.0What's new in Android Wear 2.0
What's new in Android Wear 2.0
Peter Friese
 
Google Fit, Android Wear & Xamarin
Google Fit, Android Wear & XamarinGoogle Fit, Android Wear & Xamarin
Google Fit, Android Wear & Xamarin
Peter Friese
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
Peter Friese
 
Google Play Services Rock
Google Play Services RockGoogle Play Services Rock
Google Play Services Rock
Peter Friese
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
Peter Friese
 
Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI Components
Peter Friese
 
Firebase & SwiftUI Workshop
Firebase & SwiftUI WorkshopFirebase & SwiftUI Workshop
Firebase & SwiftUI Workshop
Peter Friese
 
Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI Components
Peter Friese
 
Firebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroesFirebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroes
Peter Friese
 
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
Peter Friese
 
async/await in Swift
async/await in Swiftasync/await in Swift
async/await in Swift
Peter Friese
 
Firebase for Apple Developers
Firebase for Apple DevelopersFirebase for Apple Developers
Firebase for Apple Developers
Peter Friese
 
Building Apps with SwiftUI and Firebase
Building Apps with SwiftUI and FirebaseBuilding Apps with SwiftUI and Firebase
Building Apps with SwiftUI and Firebase
Peter Friese
 
Rapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebaseRapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and Firebase
Peter Friese
 
Rapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebaseRapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and Firebase
Peter Friese
 
6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase Auth6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase Auth
Peter Friese
 
Five Things You Didn't Know About Firebase Auth
Five Things You Didn't Know About Firebase AuthFive Things You Didn't Know About Firebase Auth
Five Things You Didn't Know About Firebase Auth
Peter Friese
 
Building High-Quality Apps for Google Assistant
Building High-Quality Apps for Google AssistantBuilding High-Quality Apps for Google Assistant
Building High-Quality Apps for Google Assistant
Peter Friese
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google
Peter Friese
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on GoogleBuilding Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google
Peter Friese
 
What's new in Android Wear 2.0
What's new in Android Wear 2.0What's new in Android Wear 2.0
What's new in Android Wear 2.0
Peter Friese
 
Google Fit, Android Wear & Xamarin
Google Fit, Android Wear & XamarinGoogle Fit, Android Wear & Xamarin
Google Fit, Android Wear & Xamarin
Peter Friese
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
Peter Friese
 
Google Play Services Rock
Google Play Services RockGoogle Play Services Rock
Google Play Services Rock
Peter Friese
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
Peter Friese
 
Ad

Recently uploaded (20)

Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
Asthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdfAsthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdf
VanessaRaudez
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
Asthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdfAsthma presentación en inglés abril 2025 pdf
Asthma presentación en inglés abril 2025 pdf
VanessaRaudez
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 

CouchDB Mobile - From Couch to 5K in 1 Hour

  • 1. 44 Peter Friese / Stefan Reichert, Zühlke Engineering CouchDB mobile From Couch To 5k in 1 Hour
  • 2. Peter Friese @peterfriese [email protected] xing.to/peter http://peterfriese.de
  • 3. Stefan Reichert @stefanreichert [email protected] xing.to/stefanreichert http://blog.wickedshell.net/
  • 4. What we will cover today 1 What is CouchDB? 2 Serious amount of demos! 3 Couch25K - A Runner’s App
  • 6. CouchDB is... CouchDB is... A NoSQL Database.
  • 7. CouchDB is... Document-Oriented. { ! "name": "Peter", ! "company": "Zühlke Engineering", ! "email": "[email protected]", ! "languages": [ ! ! "Objective-C", ! ! "Java", ! ! "C#", ! ! "JavaScript" ! ] }
  • 8. CouchDB is... Schema-Free. Put anything you like into your CouchDB. Really.
  • 9. CouchDB is... Erlang-Powered.
  • 10. CouchDB is... RESTful. GET PUT Fully embraces POST HTTP verbs DELETE
  • 12. CouchDB uses... Map/Reduce (JavaScript). Input {"ip": "212.23.45.12","traffic": “18278", date: “2012-03-11”}, {"ip": "74.12.345.1","traffic": “345", date: “2012-03-11”}, {"ip": "212.23.45.12","traffic": “112244", date: “2012-03-12”}, {"ip": "212.23.45.12","traffic": “8657", date: “2012-03-13”}, {"ip": "74.12.345.12","traffic": “12", date: “2012-03-12”}, {"ip": "10.122.111.22","traffic": “122222", date: “2012-03-11”}
  • 13. CouchDB uses... Map/Reduce (JavaScript). Mapper Input for Reducer 212.23.45.12 18278 212.23.45.12 18278 74.12.345.1 345 212.23.45.12 112244 212.23.45.12 112244 212.23.45.12 8657 212.23.45.12 8657 74.12.345.1 12 74.12.345.1 12 10.122.111.22 122222 74.12.345.1 345 10.122.111.22 122222
  • 14. CouchDB uses... Map/Reduce (JavaScript). Input for Reducer After Reduce 212.23.45.12 18278 212.23.45.12 139179 212.23.45.12 112244 212.23.45.12 8657 74.12.345.1 12 74.12.345.1 357 74.12.345.1 345 10.122.111.22 122222 10.122.111.22 122222
  • 15. CouchDB features... Robust Replication.
  • 16. CouchDB features... Robust Replication. Laptop Phone Server
  • 17. Demos 2
  • 18. Calling Home curl localhost:5984 {"couchdb":"Welcome","version":"1.1.0"}
  • 19. Creating a New DB curl -X PUT localhost:5984/helloworld {"ok":true}
  • 20. Deleting a Database curl -X DELETE http:// localhost:5984/helloworld {"ok":true}
  • 21. Creating a New Document curl -X POST -H "Content-Type: application/json" localhost:5984/helloworld -d @peter.json {"ok":true,"id":"f8e42aaa4bc77124c28 6be13f000054e","rev":"1-4dc37117e0da 26d9c50dc92d4cbb04cc"}
  • 22. Curious? GET Your Document! curl http://localhost:5984/helloworld/ f8e42aaa4bc77124c286be13f000054e { "_id": "f8e42aaa4bc77124c286be13f000054e", "_rev": "1-4dc37117e0da26d9c50dc92d4cbb04cc", "name": "Peter", "company": "Zühlke Engineering", "email": "[email protected]" }
  • 23. Anatomy of a Document { "_id": "f8e42aaa4bc77124c286be13f000054e", "_rev": "1-4dc37117e0da26d9c50dc92d4cbb04cc", "name": "Peter", "company": "Zühlke Engineering", "email": "[email protected]" } UUID - very unique identifier
  • 24. Anatomy of a Document { "_id": "f8e42aaa4bc77124c286be13f000054e", "_rev": "1-4dc37117e0da26d9c50dc92d4cbb04cc", "name": "Peter", "company": "Zühlke Engineering", "email": "[email protected]" } revision revision hash (body, number counter attachment, _deleted flag)
  • 25. Welcome to Futon! Admin interface for CouchDB CRUD for Documents Manage Views Manage Replication
  • 26. Couch25K - A Runner’s App 3
  • 27. Basic Idea 2-way 2-way Phone IrisCouch Phone
  • 28. CouchDB Mobile n e ? P h o o u r n y o
  • 29. CouchDB Mobile Your app CouchCocoa lib Ektorp lib Your app CouchDB CouchDB
  • 30. CouchDB Mobile Your app CouchCocoa lib Ektorp lib Your app TouchDB lib TouchDB lib SQlite SQlite
  • 31. CouchDB Mobile “TouchDB is a lightweight CouchDB- compatible database engine suitable for embedding into mobile or desktop apps. Think of it this way: If CouchDB is MySQL, then TouchDB is SQLite.” - Jens Alfke, Couchbase Labs
  • 32. Start a Local Couch CouchTouchDBServer *server = [CouchTouchDBServer sharedInstance]; NSAssert(!server.error, @"Error initializing TouchDB server: %@", server.error); self.database = [server databaseNamed:@"couch25k"]; NSError *error; if (! [self.database ensureCreated:&error]) { // raise error self.connected = false; }
  • 33. Start a Local Couch try { TDServer touchDBServer = new TDServer(filesDir); ! HttpClient httpClient = new TouchDBHttpClient(touchDBServer); CouchDbInstance couchDBInstance = new StdCouchDbInstance(httpClient); ! CouchDbConnector couchDBConnector = couchDBInstance.createConnector(COUCH25K_DB,true); ! ... } catch (IOException e) { ! Log.e(TAG, "Error starting TDServer", e); }
  • 34. Trackpoints { "run": "run-peterfriese-19", "user": "peterfriese", "lon": "9.990512659959458", "time": "2012-03-24 07:39:27 +0000", "lat": "53.73176022303823" }
  • 35. Saving a Trackpoint NSDictionary *trackpointProperties = [NSDictionary dictionaryWithObjectsAndKeys: (...) CouchDocument *trackpointDocument = [database untitledDocument]; RESTOperation* op = [trackpointDocument putProperties:trackpointProperties]; [op onCompletion: ^{ if (op.error) NSLog(@"Couldn't save the new item"); }]; [op start];
  • 36. Saving a Trackpoint Ektorp: JPA for CouchDB public class TrackPoint extends CouchDbDocument Repository Support public class TrackPointRepository extends ! CouchDbRepositorySupport<TrackPoint> ... so saving a TrackPoint is pretty easy trackPointRepository.add(trackPoint);
  • 37. Sync with the Server NSURL *url = [NSURL URLWithString: @"http://peterfriese.iriscouch.com/couch25k"]; [self.database replicateWithURL:url exclusively: YES];
  • 38. Sync with the Server Pull from Server ReplicationCommand commandPull = new ReplicationCommand.Builder() .source(COUCH25K_REMOTE_DB) .target(COUCH25K_DB) .continuous(true).build(); try { couchDBInstance.replicate(commandPull); } catch (Exception exception) { Log.e(TAG, exception.getMessage(), exception); }
  • 39. Sync with the Server Push to Server ReplicationCommand commandPush = new ReplicationCommand.Builder() .source(COUCH25K_DB) .target(COUCH25K_REMOTE_DB) .continuous(true).build(); try { couchDBInstance.replicate(commandPush); } catch (Exception exception) { Log.e(TAG, exception.getMessage(), exception); }
  • 40. Demo
  • 41. Display List of Runs (JavaScript) Map Reduce function(keys, values) function(doc) { { emit(doc.run, 1); return sum(values); } } run-1 1 run-1 1 run-1 3 run-1 1 run-2 2 run-2 1 run-2 1
  • 42. Display List of Runs (Obj-C) Map [design defineViewNamed: @"runs" mapBlock: MAPBLOCK({ id run = [doc objectForKey:@"run"]; if (run) emit(run, nil); }) Reduce reduceBlock:REDUCEBLOCK({ return [NSNumber numberWithInt:values.count]; })
  • 43. Display List of Runs (Java) Map new TDViewMapBlock() { public void map(Map<String, Object> doc, TDViewMapEmitBlock emitter) { if (doc.containsKey("run")) { emitter.emit(doc.get("run"), doc.get("_id")); } } }
  • 44. Display List of Runs (Java) (Re-) reduce new TDViewReduceBlock() { public Object reduce(List<Object> keys, List<Object> values, boolean rereduce) { if (rereduce) { int sum = 0; for (Object object : values) { sum += (Integer) object; } return sum; } return values.size(); } };
  • 45. Filtering Peter Stefan Filter by name sync 2-way sync 2-way Phone IrisCouch Phone 2
  • 46. Filtering CouchDB by_user: function(doc, rq) { if(doc.user == rq.query.username) { return true; } return false; }
  • 47. Filtering NSArray *replications = [self.database replicateWithURL:url exclusively: YES]; CouchPersistentReplication *from = [replications objectAtIndex:0]; from.continuous = YES; from.filter = @"couch25k/by_user"; NSDictionary *filterParams = [NSDictionary dictionaryWithObjectsAndKeys: @"peterfriese", @"username", nil]; from.query_params = filterParams;
  • 48. Filtering Map<String, Object> queryParams = new HashMap<String, Object>(); queryParams.put("username", "stefanreichert"); ReplicationCommand commandPull = new ReplicationCommand.Builder() .source(COUCH25K_REMOTE_DB) .target(COUCH25K_DB).continuous(true) .filter("by_user") .queryParams(queryParams).build(); try { ! couchDBInstance.replicate(commandPull); } catch (Exception e) { ! Log.e(TAG, exception.getMessage(), e); }
  • 50. Query Trackpoints by Run Map mapBlock: MAPBLOCK({ NSString *run = (NSString *)[doc objectForKey:@"run"]; id time = [doc objectForKey:@"time"]; NSMutableArray *key = [[NSMutableArray alloc] init]; [key addObject:run]; [key addObject:time]; emit(key, doc);}) [run-peter-1, 2012-03-23 10:10] {lat:..., lon:...} [run-peter-1, 2012-03-23 10:11] {lat:..., lon:...} [run-peter-2, 2012-03-26 20:05] {lat:..., lon:...} [run-peter-2, 2012-03-26 20:06] {lat:..., lon:...} [run-peter-2, 2012-03-26 10:07] {lat:..., lon:...}
  • 51. Query Trackpoints by Run Query CouchQuery *query = [[self.database designDocumentWithName: @"couch25k"] queryViewNamed: @"waypoints_by_run"]; CouchLiveQuery *livequery = [query asLiveQuery]; [livequery setStartKey: [NSArray arrayWithObjects:self.runKey, nil]]; [query setEndKey: [NSArray arrayWithObjects:self.runKey, @"ZZZ", nil]];
  • 52. Query Trackpoints by Run Map new TDViewMapBlock() { public void map(Map<String, Object> document, TDViewMapEmitBlock emitter) { if (document.containsKey("run")) { document.get("run"), document.get("_id")); } }
  • 53. Query Trackpoints by Run Query ViewQuery viewQuery = new ViewQuery().designDocId("_design/TrackPoint") .viewName("trackpoint_by_run") .key(runId); ViewResult result = db.queryView(viewQuery); List<TrackPoint> trackPoints = new ArrayList<TrackPoint>(); for (Row row : result.getRows()) { TrackPoint trackPoint = get(row.getValue()); trackPoints.add(trackPoint); } return trackPoints;
  • 54. And finally... http://josephta.me/about-joseph-tame/
  • 55. ... a Tribute to Steve Jobs GPX of J cou rtes ose y ph - T Tam han e ks! http://bit.ly/HbDRod
  • 57. Thanks! Peter Friese Principal Consultant rt @peterfr Zühlke Engineering GmbH @stef anreiche iese Am Sandtorkai 66 20457 Hamburg Availa ble fo +49 151 108 604 72 discu r con ssing sultin all th g, rt Reiche Engineer mobil ings Stefan Software e and Senior H frost nginee rin g Gmb y beve E Zühlke torkai 66 rages nd Am Sa rg Hambu 20457 6 961 43 3 + 49 173 PS: we’re hiring...