Basic Operations
// Geta client (pass options if needed)
var db = require('riak-js').getClient()
25.
Basic Operations
// Geta client (pass options if needed)
var db = require('riak-js').getClient()
// Fetch an object
db.get('conferences', 'nodeconf',
function(err, data) {
console.log("Found the conference:" +
sys.inspect(data))
})
26.
Basic Operations
// Geta client (pass options if needed)
var db = require('riak-js').getClient()
// Fetch an object typical node
db.get('conferences', 'nodeconf', callback style
function(err, data) {
console.log("Found the conference:" +
sys.inspect(data))
})
27.
Basic Operations
// Geta client (pass options if needed)
var db = require('riak-js').getClient()
// Fetch an object typical node
db.get('conferences', 'nodeconf', callback style
function(err, data) {
console.log("Found the conference:" +
sys.inspect(data))
})
// Store an object
db.save('conferences', 'nodeconf',
{date:"2011-05-05",
title: "nodeconf 2011",
presenters: ["Sean Cribbs"]})
Basic Operations
// Deletean object
db.remove('conferences', 'nodeconf')
// Does this key exist?
db.exists('frameworks', 'node.js')
// Stream the keys (on master)
Picture: http://www.scooponpets.com/Turtlesaspets.html
31.
Basic Operations
// Deletean object
db.remove('conferences', 'nodeconf')
// Does this key exist?
db.exists('frameworks', 'node.js')
// Stream the keys (on master)
db.keys('frameworks',{keys:'stream'}).
on('keys', cb).start()
Picture: http://www.scooponpets.com/Turtlesaspets.html
32.
Basic Operations
// Deletean object
db.remove('conferences', 'nodeconf')
// Does this key exist?
db.exists('frameworks', 'node.js')
// Stream the keys (on master)
db.keys('frameworks',{keys:'stream'}).
on('keys', cb).start()
// Give me them all
db.getAll('frameworks')
Picture: http://www.scooponpets.com/Turtlesaspets.html
33.
Basic Operations
// Deletean object
db.remove('conferences', 'nodeconf')
// Does this key exist?
db.exists('frameworks', 'node.js')
// Stream the keys (on master)
db.keys('frameworks',{keys:'stream'}).
on('keys', cb).start()
// Give me them all
db.getAll('frameworks')
Picture: http://www.scooponpets.com/Turtlesaspets.html
34.
Basic Operations
// Deletean object
db.remove('conferences', 'nodeconf')
// Does this key exist?
db.exists('frameworks', 'node.js')
// Stream the keys (on master)
db.keys('frameworks',{keys:'stream'}).
on('keys', cb).start()
// Give me them all
db.getAll('frameworks')
// How many are there? (counts keys)
Picture: http://www.scooponpets.com/Turtlesaspets.html
35.
Basic Operations
// Deletean object
db.remove('conferences', 'nodeconf')
// Does this key exist?
db.exists('frameworks', 'node.js')
// Stream the keys (on master)
db.keys('frameworks',{keys:'stream'}).
on('keys', cb).start()
// Give me them all
db.getAll('frameworks')
// How many are there? (counts keys)
db.count('frameworks')
Picture: http://www.scooponpets.com/Turtlesaspets.html
36.
Meta Object
db.save(‘bucket’, ‘key’,data, META, cb)
function cb(err, data, META){ }
Picture: http://chronotron.files.wordpress.com/2010/07/turtles.png
Using Meta
// Adda link to the object
db.get('frameworks', 'node.js',
function(err, data, meta){
meta.addLink({bucket:'vm', key:'v8', tag:'vm'});
db.save('frameworks', 'node.js', data, meta)
})
50.
Using Meta
// Adda link to the object
db.get('frameworks', 'node.js',
function(err, data, meta){
meta.addLink({bucket:'vm', key:'v8', tag:'vm'});
db.save('frameworks', 'node.js', data, meta)
})
// Set the content type
db.save('pages', 'index.html',
'<html><body>Hello, world!</body></html>',
{contentType: 'html'})
MapReduce
// Execute aMapReduce query
db.add('frameworks') // Use all keys in bucket
.map('Riak.mapValuesJson') // Map using a built-in
.run(function(err, data){ // Execute the query
console.log(data);
})
68.
MapReduce
// Execute aMapReduce query
db.add('frameworks') // Use all keys in bucket
.map('Riak.mapValuesJson') // Map using a built-in
.run(function(err, data){ // Execute the query
console.log(data);
})
// Send a focused query
db.add('frameworks', 'node.js') // Start with one key
.link({ bucket: "vm"}) // Follow some links
.map(function(obj){ // Map using an inline
var data =
Riak.mapValuesJson(obj)[0];
return [data.name]
})
.reduce('Riak.reduceSort') // Sort via reduce
.run()
etc.
• Session Store
•Mini-Riak Test Server
• Multi-protocol (HTTP, Protobuffs)
• Luwak (large files)
80.
COME AT MEBRO
Picture: http://fl.biology.usgs.gov/posters/Herpetology/Snapping_Turtles/snapping_turtles.html
Demo Time
https://github.com/basho/riaktant
#3 Like all these turtles marching toward the sea, we&#x2019;re on a path. And that path is the adoption of JavaScript in lots of places it hasn&#x2019;t been before.\n
#4 Like all these turtles marching toward the sea, we&#x2019;re on a path. And that path is the adoption of JavaScript in lots of places it hasn&#x2019;t been before.\n
#5 Like all these turtles marching toward the sea, we&#x2019;re on a path. And that path is the adoption of JavaScript in lots of places it hasn&#x2019;t been before.\n
#6 Like all these turtles marching toward the sea, we&#x2019;re on a path. And that path is the adoption of JavaScript in lots of places it hasn&#x2019;t been before.\n
#7 So you&#x2019;re probably saying &#x201C;What about CouchDB? It has JavaScript&#x201D;. \n\nCouchDB is great. I like it a lot. (apologies for the strawman) But it has been my experience that the types of applications people build on top of CouchDB are very different from the types of apps people build with Node.js. And you don&#x2019;t want to end up like this turtle.\n\nYou want to be like these turtles!\n
#8 So you&#x2019;re probably saying &#x201C;What about CouchDB? It has JavaScript&#x201D;. \n\nCouchDB is great. I like it a lot. (apologies for the strawman) But it has been my experience that the types of applications people build on top of CouchDB are very different from the types of apps people build with Node.js. And you don&#x2019;t want to end up like this turtle.\n\nYou want to be like these turtles!\n
#9 So you&#x2019;re probably saying &#x201C;What about CouchDB? It has JavaScript&#x201D;. \n\nCouchDB is great. I like it a lot. (apologies for the strawman) But it has been my experience that the types of applications people build on top of CouchDB are very different from the types of apps people build with Node.js. And you don&#x2019;t want to end up like this turtle.\n\nYou want to be like these turtles!\n
#10 So you&#x2019;re probably saying &#x201C;What about CouchDB? It has JavaScript&#x201D;. \n\nCouchDB is great. I like it a lot. (apologies for the strawman) But it has been my experience that the types of applications people build on top of CouchDB are very different from the types of apps people build with Node.js. And you don&#x2019;t want to end up like this turtle.\n\nYou want to be like these turtles!\n
#11 * &#x201C;Your data is safe with us.&#x201D;\n* &#x201C;Just add more machines.&#x201D;\n* &#x201C;Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.&#x201D;\n
#12 * &#x201C;Your data is safe with us.&#x201D;\n* &#x201C;Just add more machines.&#x201D;\n* &#x201C;Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.&#x201D;\n
#13 * &#x201C;Your data is safe with us.&#x201D;\n* &#x201C;Just add more machines.&#x201D;\n* &#x201C;Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.&#x201D;\n
#14 * &#x201C;Your data is safe with us.&#x201D;\n* &#x201C;Just add more machines.&#x201D;\n* &#x201C;Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.&#x201D;\n
#15 * &#x201C;Your data is safe with us.&#x201D;\n* &#x201C;Just add more machines.&#x201D;\n* &#x201C;Key-Value++, MapReduce, Search. With great power comes great responsibility - take ownership of your data.&#x201D;\n
#16 So if you want to work with Riak from node.js, Francisco Treacy <point him out> wrote this awesome driver called riak-js. It&#x2019;s also got a beautiful website at riakjs.org that is envy of all READMEs.\n