SlideShare a Scribd company logo
1 of 24
Download to read offline
EASY DATA FOR PHONEGAP
APPS
HOLLY SCHINSKY
PHONEGAP TEAM AT ADOBE
SOCIAL INFO
@devgirl
devgirl.org
https://github.com/hollyschinsky
COUCHDB
1st NoSQL document database created in 2005
Prefer "availability" and near real-time "consistency"
Stores unstructured "documents" using JSON
Runs on the server with RESTful API's
Designed for synchronization/replication
COUCHDB CONT...
CAP theorem ~ Partitioned, every node is
Available, and it's only eventually
Consistent.
POUCHDB?
JavaScript implementation of CouchDB for the
browser/nodejs
Mimics CouchDB API for consistency between client
and remote servers
JS abstraction layer over WebSQL, IndexedDB and
LevelDB etc
Build o ine apps that sync when back online
SAMPLE "DOCUMENT"
{
"_id": "mittens",
"name": "Mittens",
"occupation": "kitten",
"age": 3,
"hobbies": [
"playing with balls of yarn",
"chasing laser pointers",
"lookin' hella cute"
]
}
DATA SYNCHRONIZATION
Credit: http://www.ibm.com/developerworks/library/wa-couchdb/
Multiple options to replicate data between source and
target.
UNIDIRECTIONAL REPLICATION
Sync data from source to target or target to source...
localDB.replicate.to(remoteDB);
OR...
localDB.replicate.from(remoteDB);
BIDIRECTIONAL REPLICATION
Sync data from src to target AND target to src:
localDB.replicate.to(remoteDB);
localDB.replicate.from(remoteDB);
is the same as using...
localDB.sync(remoteDB, [options]);
LIVE REPLICATION
Changes propagated as they occur with liveparameter
myApp.db.sync(myApp.remoteDB, {
live: true
retry: true
}).on('change', function (change) {
console.log("A db change occurred " + change);
}).on('paused', function (info) {
console.log("Replication paused " + info);
}).on('active', function (info) {
console.log("Replication resumed " + info);
}).on('error', function (err) {
console.log("Sync Error occurred " + err);
})
FILTERED REPLICATION
Replicate partial datasets
Use case - return certain documents based on a users
identity or role
localDb.replicate.from(remoteDB, {
filter: function (doc) {
return doc.category === role;
}
}
DESIGN FOR OFFLINE FIRST
Better user experience (o ine and online)
Allow users to continue to work o ine
Avoid discontinued use of your apps
WHEN OFFLINE?
Rural Areas
3rd World Countries
Limited, Sporadic or No Access (airplanes)
OFFLINE APP USE CASES
Inspection Apps
Content Publishing (books, music, videos)
Health Care
Social Media
Location/Mapping Apps
Retail
Games
BROWSER STORAGE OPTIONS
HTML5 Storage - local storage
IndexedDB - new standard
WebSQL - deprecated
DATABASE BROWSER SUPPORT
Current defaults (can use adapters to change)
POUCHDB ADAPTERS
POUCHDB + SQLITE
Avoid storage limits of other solutions
Use WKWebView (WebSQL not available and
IndexedDB slow/buggy)
Allows you to bundle prepopulated database les
(avoid db init overhead)
Credit: http://www.html5rocks.com/en/tutorials/o ine/quota-research/#toc-mobile
MOBILE DATA STORAGE LIMITS
POUCHDB CORDOVA SQLITE ADAPTER
Provides native SQLite support w/ WebSQL like API
Use in addition to one of 3 Cordova Plugins - (
, or
)
Requires pouchdb.js (6.0.0+)
pouchdb-adapter-cordova-sqlite
Cordova-
sqlite-storage cordova-plugin-sqlite-2 cordova-
plugin-websql
myApp.localDB = new PouchDB('tasks.db', {adapter: 'cordova-sqlite'});
POUCHDB SERVER
https://github.com/pouchdb/pouchdb-serve
A simple server to mimic a CouchDB implementation
to get started quickly
Includes Web UI admin tool
$ pouchdb-server -p 15984
LOCAL/REMOTE DATABASE SETUP
// Create the local database
if (ons.platform.isIOS() || ons.platform.isAndroid())
myApp.localDB = new PouchDB('tasks.db', {adapter: 'cordova-sqlite'});
else myApp.localDB = new PouchDB('tasks.db');
// Create the remote database
myApp.remoteDB = new PouchDB("http://localhost:15984/tasks");
// Start Syncing
myApp.localDB.sync(myApp.remoteDB, {live: true, retry: true});
SAMPLE APP
Source Project:
https://github.com/hollyschinsky/PouchDB-Sample
USEFUL RESOURCES
PouchDB PhoneGap/Cordova Getting Started
PouchDB Ionic Getting Started
Cloudant DBaaS
Couchbase
PouchDB Server
Set up CouchDB Server
PouchDB Inspector
PouchDB Find
PouchDB Plugins
Database Comparison Tool

More Related Content

What's hot

Rapid Application Development on Google App Engine for Java
Rapid Application Development on Google App Engine for JavaRapid Application Development on Google App Engine for Java
Rapid Application Development on Google App Engine for JavaKunal Dabir
 
Vagrant for Effective DevOps Culture
Vagrant for Effective DevOps CultureVagrant for Effective DevOps Culture
Vagrant for Effective DevOps CultureVaidik Kapoor
 
Drupal, git and sanity
Drupal, git and sanityDrupal, git and sanity
Drupal, git and sanityCharlie Morris
 
Instant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositoriesInstant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositoriesYshay Yaacobi
 
Building production-quality apps with Node.js
Building production-quality apps with Node.jsBuilding production-quality apps with Node.js
Building production-quality apps with Node.jsmattpardee
 
[Srijan Wednesday Webinar] How to Run Stateless and Stateful Services on K8S ...
[Srijan Wednesday Webinar] How to Run Stateless and Stateful Services on K8S ...[Srijan Wednesday Webinar] How to Run Stateless and Stateful Services on K8S ...
[Srijan Wednesday Webinar] How to Run Stateless and Stateful Services on K8S ...Srijan Technologies
 
Migrating NYSenate.gov
Migrating NYSenate.govMigrating NYSenate.gov
Migrating NYSenate.govPantheon
 
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo Shift Conference
 
Sandstone HPC: A Domain General Gateway for New Users
Sandstone HPC: A Domain General Gateway for New UsersSandstone HPC: A Domain General Gateway for New Users
Sandstone HPC: A Domain General Gateway for New UsersZebula Sampedro
 
Proggis - Business Analytics with Linked Data
Proggis - Business Analytics with Linked DataProggis - Business Analytics with Linked Data
Proggis - Business Analytics with Linked DataHenri Bergius
 
Mój przepis na skalowalną architekturę mikroserwisową? Apollo Federation i Gr...
Mój przepis na skalowalną architekturę mikroserwisową? Apollo Federation i Gr...Mój przepis na skalowalną architekturę mikroserwisową? Apollo Federation i Gr...
Mój przepis na skalowalną architekturę mikroserwisową? Apollo Federation i Gr...The Software House
 
Stop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal developmentStop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal developmentkaspergarnaes
 
Isomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and ReactIsomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and ReactTyler Peterson
 
Headless Drupal: A modern approach to (micro)services and APIs
Headless Drupal: A modern approach to (micro)services and APIsHeadless Drupal: A modern approach to (micro)services and APIs
Headless Drupal: A modern approach to (micro)services and APIssparkfabrik
 
[1C5]Lessons from developing a web browser for raspberry pi
[1C5]Lessons from developing a web browser for raspberry pi[1C5]Lessons from developing a web browser for raspberry pi
[1C5]Lessons from developing a web browser for raspberry piNAVER D2
 
[Nuxeo World 2013] ADVANCED WORKFLOWS WITH CONTENT ROUTING - ALAIN ESCAFFRE
[Nuxeo World 2013] ADVANCED WORKFLOWS WITH CONTENT ROUTING - ALAIN ESCAFFRE[Nuxeo World 2013] ADVANCED WORKFLOWS WITH CONTENT ROUTING - ALAIN ESCAFFRE
[Nuxeo World 2013] ADVANCED WORKFLOWS WITH CONTENT ROUTING - ALAIN ESCAFFRENuxeo
 
Stack Exchange Infrastructure - LISA 14
Stack Exchange Infrastructure - LISA 14Stack Exchange Infrastructure - LISA 14
Stack Exchange Infrastructure - LISA 14GABeech
 
Red Hat Summit 2015 : Drools, jBPM and UberFire Roadmaps
Red Hat Summit 2015 : Drools, jBPM and UberFire RoadmapsRed Hat Summit 2015 : Drools, jBPM and UberFire Roadmaps
Red Hat Summit 2015 : Drools, jBPM and UberFire RoadmapsMark Proctor
 

What's hot (20)

Briney - Leveling Up Data Management - With Notes
Briney - Leveling Up Data Management - With NotesBriney - Leveling Up Data Management - With Notes
Briney - Leveling Up Data Management - With Notes
 
Rapid Application Development on Google App Engine for Java
Rapid Application Development on Google App Engine for JavaRapid Application Development on Google App Engine for Java
Rapid Application Development on Google App Engine for Java
 
Vagrant for Effective DevOps Culture
Vagrant for Effective DevOps CultureVagrant for Effective DevOps Culture
Vagrant for Effective DevOps Culture
 
Drupal, git and sanity
Drupal, git and sanityDrupal, git and sanity
Drupal, git and sanity
 
Instant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositoriesInstant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositories
 
Building production-quality apps with Node.js
Building production-quality apps with Node.jsBuilding production-quality apps with Node.js
Building production-quality apps with Node.js
 
Running AWS Locally
Running AWS LocallyRunning AWS Locally
Running AWS Locally
 
[Srijan Wednesday Webinar] How to Run Stateless and Stateful Services on K8S ...
[Srijan Wednesday Webinar] How to Run Stateless and Stateful Services on K8S ...[Srijan Wednesday Webinar] How to Run Stateless and Stateful Services on K8S ...
[Srijan Wednesday Webinar] How to Run Stateless and Stateful Services on K8S ...
 
Migrating NYSenate.gov
Migrating NYSenate.govMigrating NYSenate.gov
Migrating NYSenate.gov
 
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
Shift Remote: JS - Javascript Build Tools: Past & Beyond - Shedrack Akintayo
 
Sandstone HPC: A Domain General Gateway for New Users
Sandstone HPC: A Domain General Gateway for New UsersSandstone HPC: A Domain General Gateway for New Users
Sandstone HPC: A Domain General Gateway for New Users
 
Proggis - Business Analytics with Linked Data
Proggis - Business Analytics with Linked DataProggis - Business Analytics with Linked Data
Proggis - Business Analytics with Linked Data
 
Mój przepis na skalowalną architekturę mikroserwisową? Apollo Federation i Gr...
Mój przepis na skalowalną architekturę mikroserwisową? Apollo Federation i Gr...Mój przepis na skalowalną architekturę mikroserwisową? Apollo Federation i Gr...
Mój przepis na skalowalną architekturę mikroserwisową? Apollo Federation i Gr...
 
Stop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal developmentStop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal development
 
Isomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and ReactIsomorphic JavaScript with Node, WebPack, and React
Isomorphic JavaScript with Node, WebPack, and React
 
Headless Drupal: A modern approach to (micro)services and APIs
Headless Drupal: A modern approach to (micro)services and APIsHeadless Drupal: A modern approach to (micro)services and APIs
Headless Drupal: A modern approach to (micro)services and APIs
 
[1C5]Lessons from developing a web browser for raspberry pi
[1C5]Lessons from developing a web browser for raspberry pi[1C5]Lessons from developing a web browser for raspberry pi
[1C5]Lessons from developing a web browser for raspberry pi
 
[Nuxeo World 2013] ADVANCED WORKFLOWS WITH CONTENT ROUTING - ALAIN ESCAFFRE
[Nuxeo World 2013] ADVANCED WORKFLOWS WITH CONTENT ROUTING - ALAIN ESCAFFRE[Nuxeo World 2013] ADVANCED WORKFLOWS WITH CONTENT ROUTING - ALAIN ESCAFFRE
[Nuxeo World 2013] ADVANCED WORKFLOWS WITH CONTENT ROUTING - ALAIN ESCAFFRE
 
Stack Exchange Infrastructure - LISA 14
Stack Exchange Infrastructure - LISA 14Stack Exchange Infrastructure - LISA 14
Stack Exchange Infrastructure - LISA 14
 
Red Hat Summit 2015 : Drools, jBPM and UberFire Roadmaps
Red Hat Summit 2015 : Drools, jBPM and UberFire RoadmapsRed Hat Summit 2015 : Drools, jBPM and UberFire Roadmaps
Red Hat Summit 2015 : Drools, jBPM and UberFire Roadmaps
 

Similar to Easy Data for PhoneGap apps with PouchDB

Real Time Streaming with Flink & Couchbase
Real Time Streaming with Flink & CouchbaseReal Time Streaming with Flink & Couchbase
Real Time Streaming with Flink & CouchbaseManuel Hurtado
 
Pulumi iac on gcp
Pulumi iac on gcpPulumi iac on gcp
Pulumi iac on gcpVishwas N
 
Experiences using CouchDB inside Microsoft's Azure team
Experiences using CouchDB inside Microsoft's Azure teamExperiences using CouchDB inside Microsoft's Azure team
Experiences using CouchDB inside Microsoft's Azure teamBrian Benz
 
Samedi SQL Québec - La plateforme data de Azure
Samedi SQL Québec - La plateforme data de AzureSamedi SQL Québec - La plateforme data de Azure
Samedi SQL Québec - La plateforme data de AzureMSDEVMTL
 
Microsoft Azure Overview Infographic
Microsoft Azure Overview InfographicMicrosoft Azure Overview Infographic
Microsoft Azure Overview InfographicMicrosoft Azure
 
DreamFactory Essentials Webinar
DreamFactory Essentials WebinarDreamFactory Essentials Webinar
DreamFactory Essentials WebinarDreamFactory
 
Azure data bricks by Eugene Polonichko
Azure data bricks by Eugene PolonichkoAzure data bricks by Eugene Polonichko
Azure data bricks by Eugene PolonichkoAlex Tumanoff
 
Azure DataBricks for Data Engineering by Eugene Polonichko
Azure DataBricks for Data Engineering by Eugene PolonichkoAzure DataBricks for Data Engineering by Eugene Polonichko
Azure DataBricks for Data Engineering by Eugene PolonichkoDimko Zhluktenko
 
Mongodb - drupal dev days
Mongodb - drupal dev daysMongodb - drupal dev days
Mongodb - drupal dev daysPierre Joye
 
Couchbase - NoSQL for you! (SDP 2014)
Couchbase - NoSQL for you! (SDP 2014)Couchbase - NoSQL for you! (SDP 2014)
Couchbase - NoSQL for you! (SDP 2014)SirKetchup
 
NoSQL on the move
NoSQL on the moveNoSQL on the move
NoSQL on the moveCodemotion
 
Offline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM Bluemix
Offline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM BluemixOffline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM Bluemix
Offline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM BluemixIBM
 
Windows Azure HDInsight Service
Windows Azure HDInsight ServiceWindows Azure HDInsight Service
Windows Azure HDInsight ServiceNeil Mackenzie
 
Cosmos DB - Database for Serverless era
Cosmos DB - Database for Serverless eraCosmos DB - Database for Serverless era
Cosmos DB - Database for Serverless eraMichał Jankowski
 
Putting rails and couch db on the cloud - Indicthreads cloud computing confe...
Putting rails and couch db on the cloud -  Indicthreads cloud computing confe...Putting rails and couch db on the cloud -  Indicthreads cloud computing confe...
Putting rails and couch db on the cloud - Indicthreads cloud computing confe...IndicThreads
 
CouchDB and Rails on the Cloud
CouchDB and Rails on the CloudCouchDB and Rails on the Cloud
CouchDB and Rails on the Cloudrockyjaiswal
 

Similar to Easy Data for PhoneGap apps with PouchDB (20)

Real Time Streaming with Flink & Couchbase
Real Time Streaming with Flink & CouchbaseReal Time Streaming with Flink & Couchbase
Real Time Streaming with Flink & Couchbase
 
Introduction to DSpace
Introduction to DSpaceIntroduction to DSpace
Introduction to DSpace
 
Pulumi iac on gcp
Pulumi iac on gcpPulumi iac on gcp
Pulumi iac on gcp
 
Experiences using CouchDB inside Microsoft's Azure team
Experiences using CouchDB inside Microsoft's Azure teamExperiences using CouchDB inside Microsoft's Azure team
Experiences using CouchDB inside Microsoft's Azure team
 
Samedi SQL Québec - La plateforme data de Azure
Samedi SQL Québec - La plateforme data de AzureSamedi SQL Québec - La plateforme data de Azure
Samedi SQL Québec - La plateforme data de Azure
 
Microsoft Azure Overview Infographic
Microsoft Azure Overview InfographicMicrosoft Azure Overview Infographic
Microsoft Azure Overview Infographic
 
CouchDB
CouchDBCouchDB
CouchDB
 
DreamFactory Essentials Webinar
DreamFactory Essentials WebinarDreamFactory Essentials Webinar
DreamFactory Essentials Webinar
 
Azure data bricks by Eugene Polonichko
Azure data bricks by Eugene PolonichkoAzure data bricks by Eugene Polonichko
Azure data bricks by Eugene Polonichko
 
Azure DataBricks for Data Engineering by Eugene Polonichko
Azure DataBricks for Data Engineering by Eugene PolonichkoAzure DataBricks for Data Engineering by Eugene Polonichko
Azure DataBricks for Data Engineering by Eugene Polonichko
 
Mongodb - drupal dev days
Mongodb - drupal dev daysMongodb - drupal dev days
Mongodb - drupal dev days
 
Couchbase - NoSQL for you! (SDP 2014)
Couchbase - NoSQL for you! (SDP 2014)Couchbase - NoSQL for you! (SDP 2014)
Couchbase - NoSQL for you! (SDP 2014)
 
NoSQL on the move
NoSQL on the moveNoSQL on the move
NoSQL on the move
 
Offline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM Bluemix
Offline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM BluemixOffline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM Bluemix
Offline-First Mobile Web Apps with PouchDB, IBM Cloudant, and IBM Bluemix
 
Why CouchDB
Why CouchDBWhy CouchDB
Why CouchDB
 
Windows Azure HDInsight Service
Windows Azure HDInsight ServiceWindows Azure HDInsight Service
Windows Azure HDInsight Service
 
Cosmos DB - Database for Serverless era
Cosmos DB - Database for Serverless eraCosmos DB - Database for Serverless era
Cosmos DB - Database for Serverless era
 
Putting rails and couch db on the cloud - Indicthreads cloud computing confe...
Putting rails and couch db on the cloud -  Indicthreads cloud computing confe...Putting rails and couch db on the cloud -  Indicthreads cloud computing confe...
Putting rails and couch db on the cloud - Indicthreads cloud computing confe...
 
your browser, my storage
your browser, my storageyour browser, my storage
your browser, my storage
 
CouchDB and Rails on the Cloud
CouchDB and Rails on the CloudCouchDB and Rails on the Cloud
CouchDB and Rails on the Cloud
 

Easy Data for PhoneGap apps with PouchDB