SlideShare ist ein Scribd-Unternehmen logo
1 von 45
©2015 Couchbase Inc. 1
Nic Raboy, Developer Advocate at Couchbase
Quick and Easy Development with Node.js
and Couchbase Server
©2015 Couchbase Inc. 2
About Me
Nic Raboy
Developer Advocate at Couchbase
@nraboy (Twitter)
Node.js, Android, Java, Ionic Framework, NoSQL, SQL
©2015 Couchbase Inc. 3
What Is Couchbase?
©2015 Couchbase Inc. 4
What makes Couchbase unique?
4
Performance &
scalability leader
Sub millisecond latency
with high throughput;
memory-centric
architecture
Multi-
purpose
Simplified
administration
Easy to deploy &
manage; integrated
Admin Console, single-
click cluster expansion
& rebalance
Cache, key value store,
document database,
and local/mobile
database in single
platform
Always-on
availability
Data replication across
nodes, clusters, and
data centers
Enterprises choose Couchbase for several key advantages
24x365
©2015 Couchbase Inc. 5
 Consolidated cache and
database
 Tune memory required based
on application requirements
Multi-purpose database supports many uses
5
5
Tunable built-in
cache
Flexible schemas
with JSON
Couchbase Lite
 Represent data with varying
schemas using JSON on the
server or on the device
 Index and query data with
Javascript views
 Light weight embedded DB for
always available apps
 Sync Gateway syncs data
seamlessly with Couchbase
Server
©2015 Couchbase Inc. 6
Couchbase leads in performance and scalability
Auto
Sharding
Memory-memory
XDCR
Single
NodeType
 No manual sharding
 Database manages data
movement to scale out – not
the user
 Market’s only memory-to-
memory database replication
across clusters and geos
 Provides disaster recover /
data locality
 Hugely simplifies management
of clusters
 Easy to scale clusters by adding
any number of nodes
©2015 Couchbase Inc. 7
Available Couchbase Server SDKs
And more…
©2015 Couchbase Inc. 8
Overview of the Node.js SDK
©2015 Couchbase Inc. 9
Node.js SDK
 Uses the high performance Couchbase C library
 Compatible with Node.js frameworks
 Minimal coding
©2015 Couchbase Inc. 10
Node.js
// InstantiateThe Query API
var couchbase = require(“couchbase”);
var myCluster = new Couchbase.Cluster(“localhost:8091”);
var myBucket = myCluster.openBucket(“travel-sample”);
var myQuery = couchbase.N1qlQuery();
©2015 Couchbase Inc. 11
Node.js
function query(sql, done) {
var queryToRun = myQuery.fromString(sql);
myBucket.query(queryToRun, function(error, result) {
if(error) {
console.log(“ERROR: “, error);
done(error, null);
return;
}
done(null, result);
return;
});
}
©2015 Couchbase Inc. 12
Node.js
function query(sql, done) {
var queryToRun = myQuery.fromString(sql);
myBucket.query(queryToRun, function(error, result) {
if(error) {
console.log(“ERROR: “, error);
done(error, null);
return;
}
done(null, result);
return;
});
}
©2015 Couchbase Inc. 13
Node.js
function query(sql, done) {
var queryToRun = myQuery.fromString(sql);
myBucket.query(queryToRun, function(error, result) {
if(error) {
console.log(“ERROR: “, error);
done(error, null);
return;
}
done(null, result);
return;
});
}
©2015 Couchbase Inc. 14
Node.js
function query(sql, done) {
var queryToRun = myQuery.fromString(sql);
myBucket.query(queryToRun, function(error, result) {
if(error) {
console.log(“ERROR: “, error);
done(error, null);
return;
}
done(null, result);
return;
});
}
©2015 Couchbase Inc. 15
Node.js
function query(sql, done) {
var queryToRun = myQuery.fromString(sql);
myBucket.query(queryToRun, function(error, result) {
if(error) {
console.log(“ERROR: “, error);
done(error, null);
return;
}
done(null, result);
return;
});
}
©2015 Couchbase Inc. 16
Node.js
function query(sql, done) {
var queryToRun = myQuery.fromString(sql);
myBucket.query(queryToRun, function(error, result) {
if(error) {
console.log(“ERROR: “, error);
done(error, null);
return;
}
done(null, result);
return;
});
}
©2015 Couchbase Inc. 17
Node.js Data Querying
 Document lookups
 Couchbase views
 N1QL
©2015 Couchbase Inc. 18
Node.jsView Query
var query =ViewQuery.from("travel", "by_name").skip(6).limit(3);
myBucket.query(query, function(error, results) {
for(i in results) {
console.log("Row: ", results[i]);
}
});
DemoTime!
©2015 Couchbase Inc. 20
Node.js Application Design
AngularJS
Client Frontend
Node.js
Server Backend
©2015 Couchbase Inc. 21
Node.js Separation of Frontend and Backend
 No Jade markup
 API driven
 Less client and server coupling
 The backend can evolve without affecting the frontend
 Frontend can be extended to web as well as mobile
©2015 Couchbase Inc. 22
Multiple Frontends & One Backend
©2015 Couchbase Inc. 23
The Node.js Backend
©2015 Couchbase Inc. 24
Node.js Configuration
// config.json
{
"couchbase": {
"server": "127.0.0.1:8091",
"bucket": "restful-sample"
}
}
©2015 Couchbase Inc. 25
Node.js Configuration
// Project’s app.js file
var express = require("express");
var bodyParser = require("body-parser");
var couchbase = require("couchbase");
var path = require("path");
var config = require("./config");
var app = express();
©2015 Couchbase Inc. 26
Node.js Configuration
// app.js continued…
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
module.exports.bucket = (new
couchbase.Cluster(config.couchbase.server)).openBucket(config.couchbase.bucket);
app.use(express.static(path.join(__dirname, "public")));
var routes = require("./routes/routes.js")(app);
var server = app.listen(3000, function () {
console.log("Listening on port %s...", server.address().port);
});
©2015 Couchbase Inc. 27
Node.js Create or Update Endpoint
// routes.js
app.post("/api/create", function(req, res) {
if(!req.body.firstname) {
return res.status(400).send({"status": "error", "message": "A firstname is required"});
}
// …
RecordModel.create(req.body, function(error, result) {
if(error) {
return res.status(400).send(error);
}
res.send(result);
});
});
©2015 Couchbase Inc. 28
Node.js Get Document Endpoint
// routes.js continued…
app.get("/api/get", function(req, res) {
if(!req.query.document_id) {
return res.status(400).send({"status": "error", "message": "A document id is required"});
}
RecordModel.getByDocumentId(req.query.document_id, function(error, result) {
if(error) {
return res.status(400).send(error);
}
res.send(result);
});
});
©2015 Couchbase Inc. 29
Node.js Delete Endpoint
// routes.js continued…
app.post("/api/delete", function(req, res) {
if(!req.body.document_id) {
return res.status(400).send({"status": "error", "message": "A document id is required"});
}
RecordModel.delete(req.body.document_id, function(error, result) {
if(error) {
return res.status(400).send(error);
}
res.send(result);
});
});
©2015 Couchbase Inc. 30
Node.js Upsert Document Function
// recordmodel.js
RecordModel.save = function(data, callback) {
var jsonObject = {
type: “user”,
firstname: data.firstname,
lastname: data.lastname,
email: data.email
}
var documentId = data.document_id ? data.document_id : uuid.v4();
db.upsert(documentId, jsonObject, function(error, result) {
if(error) {
return callback(error, null);
}
callback(null, {message: "success", data: result});
});
}
©2015 Couchbase Inc. 31
Couchbase JSON Document
©2015 Couchbase Inc. 32
Node.js Get Document with N1QL Function
// recordmodel.js continued…
RecordModel.getByDocumentId = function(documentId, callback) {
var statement = "SELECT firstname, lastname, email " +
"FROM `" + config.couchbase.bucket + "` AS users " +
"WHERE META(users).id = $1";
var query = N1qlQuery.fromString(statement);
db.query(query, [documentId], function(error, result) {
if(error) {
return callback(error, null);
}
callback(null, result);
});
};
©2015 Couchbase Inc. 33
Node.js Delete Document Function
// recordmodel.js continued…
RecordModel.delete = function(documentId, callback) {
db.remove(documentId, function(error, result) {
if(error) {
callback(error, null);
return;
}
callback(null, {message: "success", data: result});
});
};
©2015 Couchbase Inc. 34
The AngularJS Frontend
©2015 Couchbase Inc. 35
// AngularJS app.js
$scope.fetchAll = function() {
$http(
{
method: "GET",
url: "/api/getAll"
}
)
.success(function(result) {
for(var i = 0; i < result.length; i++) {
$scope.items[result[i].id] = result[i];
}
});
}
©2015 Couchbase Inc. 36
// AngularJS app.s
$scope.save = function(firstname, lastname, email) {
$http(
{
method: "POST",
url: "/api/create",
data: {
firstname: firstname,
lastname: lastname,
email: email,
document_id: $stateParams.documentId
}
}
)
}
A Further Look AtThe Code…
©2015 Couchbase Inc. 38
More Complex Node.js Queries
©2015 Couchbase Inc. 39
Node.jsTravel Sample
FlightPath.findAll = function(documentId, callback) {
var statement = "SELECT faa AS fromAirport, geo " +
"FROM `" + config.couchbase.bucket + "` r" +
"WHERE airportname = $1 " +
"UNION SELECT faa AS toAirport, geo " +
"FROM `" + config.couchbase.bucket + "` r" +
"WHERE airportname = $2";
var query = N1qlQuery.fromString(statement);
db.query(query, [from, to], function(error, result) {
if(error) {
return callback(error, null);
}
callback(null, result);
});
};
©2015 Couchbase Inc. 40
Node.jsTravel Sample
FlightPath.findAll = function(documentId, callback) {
var statement = "SELECT r.id, a.name, s.flight, s.utc, r.sourceairport, r.destinationairport, r.equipment " +
"FROM `" + config.couchbase.bucket + "` r" +
"UNNEST r.schedule s " +
"JOIN `" + config.couchbase.bucket + "` a ON KEYS r.airlineid " +
"WHERE r.sourceairport = $1AND r.destinationairport = $2AND s.day = $3 ”
"ORDER BY a.name";
var query = N1qlQuery.fromString(statement);
db.query(query, [queryFrom, queryTo, leave], function(error, result) {
if(error) {
return callback(error, null);
}
callback(null, result);
});
};
©2015 Couchbase Inc. 41
Node.js Sample Applications
https://github.com/couchbaselabs/try-cb-nodejs
https://github.com/couchbaselabs/restful-angularjs-nodejs
©2015 Couchbase Inc. 42
Couchbase N1QLTutorial
http://query.pub.couchbase.com/tutorial
Questions?
©2014 Couchbase, Inc.
©2015 Couchbase Inc. 44
Couchbase
We’re Hiring!
©2014 Couchbase, Inc.
©2015 Couchbase Inc. 45©2014 Couchbase, Inc.
ThankYou
Nic Raboy
Developer Advocate at Couchbase
@nraboy (Twitter)

Weitere ähnliche Inhalte

Was ist angesagt?

Google App Engine/ Java Application Development
Google App Engine/ Java Application DevelopmentGoogle App Engine/ Java Application Development
Google App Engine/ Java Application DevelopmentShuji Watanabe
 
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...Sencha
 
Azure and web sites hackaton deck
Azure and web sites hackaton deckAzure and web sites hackaton deck
Azure and web sites hackaton deckAlexey Bokov
 
Google App Engine (GAE) 演進史
Google App Engine (GAE) 演進史Google App Engine (GAE) 演進史
Google App Engine (GAE) 演進史Simon Su
 
Using ActiveObjects in Atlassian Plugins
Using ActiveObjects in Atlassian PluginsUsing ActiveObjects in Atlassian Plugins
Using ActiveObjects in Atlassian PluginsAtlassian
 
Akka and AngularJS – Reactive Applications in Practice
Akka and AngularJS – Reactive Applications in PracticeAkka and AngularJS – Reactive Applications in Practice
Akka and AngularJS – Reactive Applications in PracticeRoland Kuhn
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance DrupalJeff Geerling
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSGunnar Hillert
 
Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018DocFluix, LLC
 
Cloud Foundry Deployment Tools: BOSH vs Juju Charms
Cloud Foundry Deployment Tools:  BOSH vs Juju CharmsCloud Foundry Deployment Tools:  BOSH vs Juju Charms
Cloud Foundry Deployment Tools: BOSH vs Juju CharmsAltoros
 
Architectural changes in the repo in 6.1 and beyond
Architectural changes in the repo in 6.1 and beyondArchitectural changes in the repo in 6.1 and beyond
Architectural changes in the repo in 6.1 and beyondStefan Kopf
 
Docker. Does it matter for Java developer ?
Docker. Does it matter for Java developer ?Docker. Does it matter for Java developer ?
Docker. Does it matter for Java developer ?Izzet Mustafaiev
 
Deploying and running Grails in the cloud
Deploying and running Grails in the cloudDeploying and running Grails in the cloud
Deploying and running Grails in the cloudPhilip Stehlik
 
GigaSpaces Cloudify - The PaaS Jailbreaker
GigaSpaces Cloudify - The PaaS Jailbreaker GigaSpaces Cloudify - The PaaS Jailbreaker
GigaSpaces Cloudify - The PaaS Jailbreaker Uri Cohen
 
Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deploymentKarthik .P.R
 
Creating Real-Time Data Mashups with Node.JS and Adobe CQ
Creating Real-Time Data Mashups with Node.JS and Adobe CQCreating Real-Time Data Mashups with Node.JS and Adobe CQ
Creating Real-Time Data Mashups with Node.JS and Adobe CQiCiDIGITAL
 
Sql source control
Sql source controlSql source control
Sql source controlAndyPickett
 

Was ist angesagt? (20)

Google App Engine/ Java Application Development
Google App Engine/ Java Application DevelopmentGoogle App Engine/ Java Application Development
Google App Engine/ Java Application Development
 
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
 
Azure and web sites hackaton deck
Azure and web sites hackaton deckAzure and web sites hackaton deck
Azure and web sites hackaton deck
 
Google App Engine (GAE) 演進史
Google App Engine (GAE) 演進史Google App Engine (GAE) 演進史
Google App Engine (GAE) 演進史
 
Using ActiveObjects in Atlassian Plugins
Using ActiveObjects in Atlassian PluginsUsing ActiveObjects in Atlassian Plugins
Using ActiveObjects in Atlassian Plugins
 
Akka and AngularJS – Reactive Applications in Practice
Akka and AngularJS – Reactive Applications in PracticeAkka and AngularJS – Reactive Applications in Practice
Akka and AngularJS – Reactive Applications in Practice
 
Lspe
LspeLspe
Lspe
 
Azkaban
AzkabanAzkaban
Azkaban
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance Drupal
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJS
 
Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018Developing Azure Functions for Flow and Nintex SPS SD 2018
Developing Azure Functions for Flow and Nintex SPS SD 2018
 
Cloud Foundry Deployment Tools: BOSH vs Juju Charms
Cloud Foundry Deployment Tools:  BOSH vs Juju CharmsCloud Foundry Deployment Tools:  BOSH vs Juju Charms
Cloud Foundry Deployment Tools: BOSH vs Juju Charms
 
Architectural changes in the repo in 6.1 and beyond
Architectural changes in the repo in 6.1 and beyondArchitectural changes in the repo in 6.1 and beyond
Architectural changes in the repo in 6.1 and beyond
 
Docker. Does it matter for Java developer ?
Docker. Does it matter for Java developer ?Docker. Does it matter for Java developer ?
Docker. Does it matter for Java developer ?
 
Deploying and running Grails in the cloud
Deploying and running Grails in the cloudDeploying and running Grails in the cloud
Deploying and running Grails in the cloud
 
GigaSpaces Cloudify - The PaaS Jailbreaker
GigaSpaces Cloudify - The PaaS Jailbreaker GigaSpaces Cloudify - The PaaS Jailbreaker
GigaSpaces Cloudify - The PaaS Jailbreaker
 
Iac d.damyanov 4.pptx
Iac d.damyanov 4.pptxIac d.damyanov 4.pptx
Iac d.damyanov 4.pptx
 
Ansible for large scale deployment
Ansible for large scale deploymentAnsible for large scale deployment
Ansible for large scale deployment
 
Creating Real-Time Data Mashups with Node.JS and Adobe CQ
Creating Real-Time Data Mashups with Node.JS and Adobe CQCreating Real-Time Data Mashups with Node.JS and Adobe CQ
Creating Real-Time Data Mashups with Node.JS and Adobe CQ
 
Sql source control
Sql source controlSql source control
Sql source control
 

Andere mochten auch

Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)Red Hat Developers
 
Syllabus B.Pharm 2008-09
Syllabus B.Pharm 2008-09Syllabus B.Pharm 2008-09
Syllabus B.Pharm 2008-09Imran Nur Manik
 
Sldo.Guaman Jose Luis docencia
Sldo.Guaman Jose Luis docenciaSldo.Guaman Jose Luis docencia
Sldo.Guaman Jose Luis docenciaNoizery
 
Portfolio Sept 2015
Portfolio Sept 2015Portfolio Sept 2015
Portfolio Sept 2015Rahul Sharma
 
Historia del internet
Historia del internetHistoria del internet
Historia del internetFerBarcenas
 
Gráficas de control
Gráficas de controlGráficas de control
Gráficas de controlAlbertoHT
 

Andere mochten auch (8)

Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
 
Syllabus B.Pharm 2008-09
Syllabus B.Pharm 2008-09Syllabus B.Pharm 2008-09
Syllabus B.Pharm 2008-09
 
Xarxes socials
Xarxes socialsXarxes socials
Xarxes socials
 
Sldo.Guaman Jose Luis docencia
Sldo.Guaman Jose Luis docenciaSldo.Guaman Jose Luis docencia
Sldo.Guaman Jose Luis docencia
 
Level booklet
Level bookletLevel booklet
Level booklet
 
Portfolio Sept 2015
Portfolio Sept 2015Portfolio Sept 2015
Portfolio Sept 2015
 
Historia del internet
Historia del internetHistoria del internet
Historia del internet
 
Gráficas de control
Gráficas de controlGráficas de control
Gráficas de control
 

Ähnlich wie Quick and Easy Development with Node.js and Couchbase Server

Full stack development with Node and NoSQL - Austin Node.JS Group - October ...
Full stack development with Node and NoSQL -  Austin Node.JS Group - October ...Full stack development with Node and NoSQL -  Austin Node.JS Group - October ...
Full stack development with Node and NoSQL - Austin Node.JS Group - October ...Matthew Groves
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gearsdion
 
Serverless in-action
Serverless in-actionServerless in-action
Serverless in-actionAssaf Gannon
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSGunnar Hillert
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Running Vue Storefront in production (PWA Magento webshop)
Running Vue Storefront in production (PWA Magento webshop)Running Vue Storefront in production (PWA Magento webshop)
Running Vue Storefront in production (PWA Magento webshop)Vendic Magento, PWA & Marketing
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Matthew Groves
 
Full Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLFull Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLAll Things Open
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineRicardo Silva
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js frameworkBen Lin
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Eliran Eliassy
 
Vertx - Reactive & Distributed
Vertx - Reactive & DistributedVertx - Reactive & Distributed
Vertx - Reactive & DistributedOrkhan Gasimov
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenerytoddbr
 
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 platformsAyush Sharma
 
JAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJosé Paumard
 
Rails 6 frontend frameworks
Rails 6 frontend frameworksRails 6 frontend frameworks
Rails 6 frontend frameworksEric Guo
 

Ähnlich wie Quick and Easy Development with Node.js and Couchbase Server (20)

Full stack development with Node and NoSQL - Austin Node.JS Group - October ...
Full stack development with Node and NoSQL -  Austin Node.JS Group - October ...Full stack development with Node and NoSQL -  Austin Node.JS Group - October ...
Full stack development with Node and NoSQL - Austin Node.JS Group - October ...
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gears
 
Serverless in-action
Serverless in-actionServerless in-action
Serverless in-action
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJS
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Running Vue Storefront in production (PWA Magento webshop)
Running Vue Storefront in production (PWA Magento webshop)Running Vue Storefront in production (PWA Magento webshop)
Running Vue Storefront in production (PWA Magento webshop)
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 
Full Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLFull Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQL
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
mobl
moblmobl
mobl
 
Arquitecturas de microservicios - Medianet Software
Arquitecturas de microservicios   -  Medianet SoftwareArquitecturas de microservicios   -  Medianet Software
Arquitecturas de microservicios - Medianet Software
 
Vertx - Reactive & Distributed
Vertx - Reactive & DistributedVertx - Reactive & Distributed
Vertx - Reactive & Distributed
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
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
 
JAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) Bridge
 
Rails 6 frontend frameworks
Rails 6 frontend frameworksRails 6 frontend frameworks
Rails 6 frontend frameworks
 

Mehr von Nic Raboy

Getting Started with MongoDB using Node.js
Getting Started with MongoDB using Node.jsGetting Started with MongoDB using Node.js
Getting Started with MongoDB using Node.jsNic Raboy
 
Marketing and Workflow Automation
Marketing and Workflow AutomationMarketing and Workflow Automation
Marketing and Workflow AutomationNic Raboy
 
Create a Chatbot with AWS Lex, Lambda, and HERE
Create a Chatbot with AWS Lex, Lambda, and HERECreate a Chatbot with AWS Lex, Lambda, and HERE
Create a Chatbot with AWS Lex, Lambda, and HERENic Raboy
 
Developing Amazon Alexa Skills with the Go Programming Language
Developing Amazon Alexa Skills with the Go Programming LanguageDeveloping Amazon Alexa Skills with the Go Programming Language
Developing Amazon Alexa Skills with the Go Programming LanguageNic Raboy
 
Static Site Generation with Hugo and Markdown
Static Site Generation with Hugo and MarkdownStatic Site Generation with Hugo and Markdown
Static Site Generation with Hugo and MarkdownNic Raboy
 
Powering an API with GraphQL, Golang, and NoSQL
Powering an API with GraphQL, Golang, and NoSQLPowering an API with GraphQL, Golang, and NoSQL
Powering an API with GraphQL, Golang, and NoSQLNic Raboy
 
Building a Bitcoin Hardware Wallet with Golang and a Raspberry Pi Zero
Building a Bitcoin Hardware Wallet with Golang and a Raspberry Pi ZeroBuilding a Bitcoin Hardware Wallet with Golang and a Raspberry Pi Zero
Building a Bitcoin Hardware Wallet with Golang and a Raspberry Pi ZeroNic Raboy
 
Developing Applications with Go and NoSQL
Developing Applications with Go and NoSQLDeveloping Applications with Go and NoSQL
Developing Applications with Go and NoSQLNic Raboy
 
Native to Hybrid and Back Again
Native to Hybrid and Back AgainNative to Hybrid and Back Again
Native to Hybrid and Back AgainNic Raboy
 
Developing for Offline First Mobile Experiences
Developing for Offline First Mobile ExperiencesDeveloping for Offline First Mobile Experiences
Developing for Offline First Mobile ExperiencesNic Raboy
 

Mehr von Nic Raboy (10)

Getting Started with MongoDB using Node.js
Getting Started with MongoDB using Node.jsGetting Started with MongoDB using Node.js
Getting Started with MongoDB using Node.js
 
Marketing and Workflow Automation
Marketing and Workflow AutomationMarketing and Workflow Automation
Marketing and Workflow Automation
 
Create a Chatbot with AWS Lex, Lambda, and HERE
Create a Chatbot with AWS Lex, Lambda, and HERECreate a Chatbot with AWS Lex, Lambda, and HERE
Create a Chatbot with AWS Lex, Lambda, and HERE
 
Developing Amazon Alexa Skills with the Go Programming Language
Developing Amazon Alexa Skills with the Go Programming LanguageDeveloping Amazon Alexa Skills with the Go Programming Language
Developing Amazon Alexa Skills with the Go Programming Language
 
Static Site Generation with Hugo and Markdown
Static Site Generation with Hugo and MarkdownStatic Site Generation with Hugo and Markdown
Static Site Generation with Hugo and Markdown
 
Powering an API with GraphQL, Golang, and NoSQL
Powering an API with GraphQL, Golang, and NoSQLPowering an API with GraphQL, Golang, and NoSQL
Powering an API with GraphQL, Golang, and NoSQL
 
Building a Bitcoin Hardware Wallet with Golang and a Raspberry Pi Zero
Building a Bitcoin Hardware Wallet with Golang and a Raspberry Pi ZeroBuilding a Bitcoin Hardware Wallet with Golang and a Raspberry Pi Zero
Building a Bitcoin Hardware Wallet with Golang and a Raspberry Pi Zero
 
Developing Applications with Go and NoSQL
Developing Applications with Go and NoSQLDeveloping Applications with Go and NoSQL
Developing Applications with Go and NoSQL
 
Native to Hybrid and Back Again
Native to Hybrid and Back AgainNative to Hybrid and Back Again
Native to Hybrid and Back Again
 
Developing for Offline First Mobile Experiences
Developing for Offline First Mobile ExperiencesDeveloping for Offline First Mobile Experiences
Developing for Offline First Mobile Experiences
 

Kürzlich hochgeladen

MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 

Kürzlich hochgeladen (20)

MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 

Quick and Easy Development with Node.js and Couchbase Server

  • 1. ©2015 Couchbase Inc. 1 Nic Raboy, Developer Advocate at Couchbase Quick and Easy Development with Node.js and Couchbase Server
  • 2. ©2015 Couchbase Inc. 2 About Me Nic Raboy Developer Advocate at Couchbase @nraboy (Twitter) Node.js, Android, Java, Ionic Framework, NoSQL, SQL
  • 3. ©2015 Couchbase Inc. 3 What Is Couchbase?
  • 4. ©2015 Couchbase Inc. 4 What makes Couchbase unique? 4 Performance & scalability leader Sub millisecond latency with high throughput; memory-centric architecture Multi- purpose Simplified administration Easy to deploy & manage; integrated Admin Console, single- click cluster expansion & rebalance Cache, key value store, document database, and local/mobile database in single platform Always-on availability Data replication across nodes, clusters, and data centers Enterprises choose Couchbase for several key advantages 24x365
  • 5. ©2015 Couchbase Inc. 5  Consolidated cache and database  Tune memory required based on application requirements Multi-purpose database supports many uses 5 5 Tunable built-in cache Flexible schemas with JSON Couchbase Lite  Represent data with varying schemas using JSON on the server or on the device  Index and query data with Javascript views  Light weight embedded DB for always available apps  Sync Gateway syncs data seamlessly with Couchbase Server
  • 6. ©2015 Couchbase Inc. 6 Couchbase leads in performance and scalability Auto Sharding Memory-memory XDCR Single NodeType  No manual sharding  Database manages data movement to scale out – not the user  Market’s only memory-to- memory database replication across clusters and geos  Provides disaster recover / data locality  Hugely simplifies management of clusters  Easy to scale clusters by adding any number of nodes
  • 7. ©2015 Couchbase Inc. 7 Available Couchbase Server SDKs And more…
  • 8. ©2015 Couchbase Inc. 8 Overview of the Node.js SDK
  • 9. ©2015 Couchbase Inc. 9 Node.js SDK  Uses the high performance Couchbase C library  Compatible with Node.js frameworks  Minimal coding
  • 10. ©2015 Couchbase Inc. 10 Node.js // InstantiateThe Query API var couchbase = require(“couchbase”); var myCluster = new Couchbase.Cluster(“localhost:8091”); var myBucket = myCluster.openBucket(“travel-sample”); var myQuery = couchbase.N1qlQuery();
  • 11. ©2015 Couchbase Inc. 11 Node.js function query(sql, done) { var queryToRun = myQuery.fromString(sql); myBucket.query(queryToRun, function(error, result) { if(error) { console.log(“ERROR: “, error); done(error, null); return; } done(null, result); return; }); }
  • 12. ©2015 Couchbase Inc. 12 Node.js function query(sql, done) { var queryToRun = myQuery.fromString(sql); myBucket.query(queryToRun, function(error, result) { if(error) { console.log(“ERROR: “, error); done(error, null); return; } done(null, result); return; }); }
  • 13. ©2015 Couchbase Inc. 13 Node.js function query(sql, done) { var queryToRun = myQuery.fromString(sql); myBucket.query(queryToRun, function(error, result) { if(error) { console.log(“ERROR: “, error); done(error, null); return; } done(null, result); return; }); }
  • 14. ©2015 Couchbase Inc. 14 Node.js function query(sql, done) { var queryToRun = myQuery.fromString(sql); myBucket.query(queryToRun, function(error, result) { if(error) { console.log(“ERROR: “, error); done(error, null); return; } done(null, result); return; }); }
  • 15. ©2015 Couchbase Inc. 15 Node.js function query(sql, done) { var queryToRun = myQuery.fromString(sql); myBucket.query(queryToRun, function(error, result) { if(error) { console.log(“ERROR: “, error); done(error, null); return; } done(null, result); return; }); }
  • 16. ©2015 Couchbase Inc. 16 Node.js function query(sql, done) { var queryToRun = myQuery.fromString(sql); myBucket.query(queryToRun, function(error, result) { if(error) { console.log(“ERROR: “, error); done(error, null); return; } done(null, result); return; }); }
  • 17. ©2015 Couchbase Inc. 17 Node.js Data Querying  Document lookups  Couchbase views  N1QL
  • 18. ©2015 Couchbase Inc. 18 Node.jsView Query var query =ViewQuery.from("travel", "by_name").skip(6).limit(3); myBucket.query(query, function(error, results) { for(i in results) { console.log("Row: ", results[i]); } });
  • 20. ©2015 Couchbase Inc. 20 Node.js Application Design AngularJS Client Frontend Node.js Server Backend
  • 21. ©2015 Couchbase Inc. 21 Node.js Separation of Frontend and Backend  No Jade markup  API driven  Less client and server coupling  The backend can evolve without affecting the frontend  Frontend can be extended to web as well as mobile
  • 22. ©2015 Couchbase Inc. 22 Multiple Frontends & One Backend
  • 23. ©2015 Couchbase Inc. 23 The Node.js Backend
  • 24. ©2015 Couchbase Inc. 24 Node.js Configuration // config.json { "couchbase": { "server": "127.0.0.1:8091", "bucket": "restful-sample" } }
  • 25. ©2015 Couchbase Inc. 25 Node.js Configuration // Project’s app.js file var express = require("express"); var bodyParser = require("body-parser"); var couchbase = require("couchbase"); var path = require("path"); var config = require("./config"); var app = express();
  • 26. ©2015 Couchbase Inc. 26 Node.js Configuration // app.js continued… app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); module.exports.bucket = (new couchbase.Cluster(config.couchbase.server)).openBucket(config.couchbase.bucket); app.use(express.static(path.join(__dirname, "public"))); var routes = require("./routes/routes.js")(app); var server = app.listen(3000, function () { console.log("Listening on port %s...", server.address().port); });
  • 27. ©2015 Couchbase Inc. 27 Node.js Create or Update Endpoint // routes.js app.post("/api/create", function(req, res) { if(!req.body.firstname) { return res.status(400).send({"status": "error", "message": "A firstname is required"}); } // … RecordModel.create(req.body, function(error, result) { if(error) { return res.status(400).send(error); } res.send(result); }); });
  • 28. ©2015 Couchbase Inc. 28 Node.js Get Document Endpoint // routes.js continued… app.get("/api/get", function(req, res) { if(!req.query.document_id) { return res.status(400).send({"status": "error", "message": "A document id is required"}); } RecordModel.getByDocumentId(req.query.document_id, function(error, result) { if(error) { return res.status(400).send(error); } res.send(result); }); });
  • 29. ©2015 Couchbase Inc. 29 Node.js Delete Endpoint // routes.js continued… app.post("/api/delete", function(req, res) { if(!req.body.document_id) { return res.status(400).send({"status": "error", "message": "A document id is required"}); } RecordModel.delete(req.body.document_id, function(error, result) { if(error) { return res.status(400).send(error); } res.send(result); }); });
  • 30. ©2015 Couchbase Inc. 30 Node.js Upsert Document Function // recordmodel.js RecordModel.save = function(data, callback) { var jsonObject = { type: “user”, firstname: data.firstname, lastname: data.lastname, email: data.email } var documentId = data.document_id ? data.document_id : uuid.v4(); db.upsert(documentId, jsonObject, function(error, result) { if(error) { return callback(error, null); } callback(null, {message: "success", data: result}); }); }
  • 31. ©2015 Couchbase Inc. 31 Couchbase JSON Document
  • 32. ©2015 Couchbase Inc. 32 Node.js Get Document with N1QL Function // recordmodel.js continued… RecordModel.getByDocumentId = function(documentId, callback) { var statement = "SELECT firstname, lastname, email " + "FROM `" + config.couchbase.bucket + "` AS users " + "WHERE META(users).id = $1"; var query = N1qlQuery.fromString(statement); db.query(query, [documentId], function(error, result) { if(error) { return callback(error, null); } callback(null, result); }); };
  • 33. ©2015 Couchbase Inc. 33 Node.js Delete Document Function // recordmodel.js continued… RecordModel.delete = function(documentId, callback) { db.remove(documentId, function(error, result) { if(error) { callback(error, null); return; } callback(null, {message: "success", data: result}); }); };
  • 34. ©2015 Couchbase Inc. 34 The AngularJS Frontend
  • 35. ©2015 Couchbase Inc. 35 // AngularJS app.js $scope.fetchAll = function() { $http( { method: "GET", url: "/api/getAll" } ) .success(function(result) { for(var i = 0; i < result.length; i++) { $scope.items[result[i].id] = result[i]; } }); }
  • 36. ©2015 Couchbase Inc. 36 // AngularJS app.s $scope.save = function(firstname, lastname, email) { $http( { method: "POST", url: "/api/create", data: { firstname: firstname, lastname: lastname, email: email, document_id: $stateParams.documentId } } ) }
  • 37. A Further Look AtThe Code…
  • 38. ©2015 Couchbase Inc. 38 More Complex Node.js Queries
  • 39. ©2015 Couchbase Inc. 39 Node.jsTravel Sample FlightPath.findAll = function(documentId, callback) { var statement = "SELECT faa AS fromAirport, geo " + "FROM `" + config.couchbase.bucket + "` r" + "WHERE airportname = $1 " + "UNION SELECT faa AS toAirport, geo " + "FROM `" + config.couchbase.bucket + "` r" + "WHERE airportname = $2"; var query = N1qlQuery.fromString(statement); db.query(query, [from, to], function(error, result) { if(error) { return callback(error, null); } callback(null, result); }); };
  • 40. ©2015 Couchbase Inc. 40 Node.jsTravel Sample FlightPath.findAll = function(documentId, callback) { var statement = "SELECT r.id, a.name, s.flight, s.utc, r.sourceairport, r.destinationairport, r.equipment " + "FROM `" + config.couchbase.bucket + "` r" + "UNNEST r.schedule s " + "JOIN `" + config.couchbase.bucket + "` a ON KEYS r.airlineid " + "WHERE r.sourceairport = $1AND r.destinationairport = $2AND s.day = $3 ” "ORDER BY a.name"; var query = N1qlQuery.fromString(statement); db.query(query, [queryFrom, queryTo, leave], function(error, result) { if(error) { return callback(error, null); } callback(null, result); }); };
  • 41. ©2015 Couchbase Inc. 41 Node.js Sample Applications https://github.com/couchbaselabs/try-cb-nodejs https://github.com/couchbaselabs/restful-angularjs-nodejs
  • 42. ©2015 Couchbase Inc. 42 Couchbase N1QLTutorial http://query.pub.couchbase.com/tutorial
  • 44. ©2015 Couchbase Inc. 44 Couchbase We’re Hiring! ©2014 Couchbase, Inc.
  • 45. ©2015 Couchbase Inc. 45©2014 Couchbase, Inc. ThankYou Nic Raboy Developer Advocate at Couchbase @nraboy (Twitter)

Hinweis der Redaktion

  1. Couchbase has emerged as a leading NoSQL provider for number of reasons: Best in performance and scalability We’ve engineered Couchbase from the ground up for high performance and scalability Couchbase is designed to deliver sub-millisecond responsiveness with very high throughput for both reads and writes We consistently outperform competitors like MongoDB and DataStax in multiple independent benchmarks Our performance advantage is driven in large part by our memory-centric architecture, which includes an integrated managed object cache and stream-based replication Broad use case support We’re the only NoSQL provider that has consolidated distributed cache, key-value store, and a JSON-based document database in a single platform This means customers can use Couchbase for a much broader range of applications Integrated mobile solution We’re the only vendor that provides an end-to-end NoSQL mobile solution -- allows customers to easily build mobile apps that run great on or offline Includes a JSON database embedded on the device, along with a prebuilt syncing tier So apps run great on the device, even without a network connection or no connectivity at all Data on the device auto-syncs with the backend server when a connection is available Simplified administration We’ve designed Couchbase to be exceptionally easy to deploy and manage Features such as an integrated Admin Console and single-click cluster expansion & rebalance dramatically increase admin efficiency