24. Basic Operations
// Get a client (pass options if needed)
var db = require('riak-js').getClient()
25. Basic Operations
// Get a 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
// Get a 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
// Get a 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"]})
30. Basic Operations
// Delete an 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
// Delete an 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
// Delete an 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
// Delete an 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
// Delete an 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
// Delete an 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
49. Using Meta
// Add a 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
// Add a 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'})
67. MapReduce
// Execute a MapReduce 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 a MapReduce 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()
79. etc.
• Session Store
• Mini-Riak Test Server
• Multi-protocol (HTTP, Protobuffs)
• Luwak (large files)
80. COME AT ME BRO
Picture: http://fl.biology.usgs.gov/posters/Herpetology/Snapping_Turtles/snapping_turtles.html
Demo Time
https://github.com/basho/riaktant
83. Riak on Turtles
(someday)
Picture: http://scienceblogs.com/bioephemera/2008/07/gpsequipped_box_turtle_leads_p.php
Editor's Notes
\n
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
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
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
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
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
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
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
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
* &#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
* &#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
* &#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
* &#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
* &#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
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
\n
\n
\n
\n
\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n
Pretty much every API function takes a callback which receives the results - will be eliding the callback except where necessary.\n