Your SlideShare is downloading. ×
0
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Riak with node.js
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Riak with node.js

11,531

Published on

Learn how to use Riak with node.js applications.

Learn how to use Riak with node.js applications.

Published in: Technology
0 Comments
11 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
11,531
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
118
Comments
0
Likes
11
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • Erlang Factory SF Bay next week - Free Erlounge Thursday night\nSponsoring JSConf and NodeConf May 1-5\nPossible Riak hackathon in PDX, contact Mark about any events\n
  • * Key-value API, mostly, over HTTP\n* key-value, search, large files || RAM, disk\n* riak-js rules\n* Demo will show a write-heavy app\n
  • * Key-value API, mostly, over HTTP\n* key-value, search, large files || RAM, disk\n* riak-js rules\n* Demo will show a write-heavy app\n
  • * Key-value API, mostly, over HTTP\n* key-value, search, large files || RAM, disk\n* riak-js rules\n* Demo will show a write-heavy app\n
  • * Key-value API, mostly, over HTTP\n* key-value, search, large files || RAM, disk\n* riak-js rules\n* Demo will show a write-heavy app\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
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. Riak with node.js Sean Cribbs Mathias Meyer Developer Advocatesbasho
    • 2. Upcoming Events Mark Phillips, Community Manager mark@basho.com @pharkmillupsbasho
    • 3. Why Riak with node.js?basho
    • 4. Why Riak with node.js? • Simple to understand and usebasho
    • 5. Why Riak with node.js? • Simple to understand and use • Flexible storage optionsbasho
    • 6. Why Riak with node.js? • Simple to understand and use • Flexible storage options • Awesome client library (riak-js)basho
    • 7. Why Riak with node.js? • Simple to understand and use • Flexible storage options • Awesome client library (riak-js) • Fits lots of use-casesbasho
    • 8. Getting Startedbasho
    • 9. Getting Started Install Riak or Riak Search: http://downloads.basho.combasho
    • 10. Getting Started Install Riak or Riak Search: http://downloads.basho.com $ npm install riak-jsbasho
    • 11. Getting Started Install Riak or Riak Search: http://downloads.basho.com $ npm install riak-js $ git clone git://github.com/frank06/riak-jsbasho
    • 12. Getting Started Install Riak or Riak Search: http://downloads.basho.com $ npm install riak-js $ git clone git://github.com/frank06/riak-js Website: http://riakjs.orgbasho
    • 13. Basic Client Operationsbasho
    • 14. Basic Operationsbasho
    • 15. Basic Operations // Get a client var db = require(riak-js).getClient()basho
    • 16. Basic Operations // Get a client var db = require(riak-js).getClient() // Fetch an object db.get(webinars, node.js,   function(err, data) {     console.log("Found the webinar:" + sys.inspect(data))   })basho
    • 17. Basic Operations // Get a client var db = require(riak-js).getClient() // Fetch an object typical node db.get(webinars, node.js, callback style   function(err, data) {     console.log("Found the webinar:" + sys.inspect(data))   })basho
    • 18. Basic Operations // Get a client var db = require(riak-js).getClient() // Fetch an object typical node db.get(webinars, node.js, callback style   function(err, data) {     console.log("Found the webinar:" + sys.inspect(data))   }) // Store an object db.save(webinars, node.js,         {date:"2011-03-15",          title: "Riak with node.js",          presenters: ["Sean", "Mathias"]})basho
    • 19. Basic Operationsbasho
    • 20. Basic Operations // Delete an object db.remove(webinars, node.js)basho
    • 21. Basic Operations // Delete an object db.remove(webinars, node.js) // Does this key exist? db.exists(frameworks, node.js)basho
    • 22. Basic Operations // Delete an object db.remove(webinars, node.js) // Does this key exist? db.exists(frameworks, node.js) // Give me them all db.getAll(frameworks)basho
    • 23. Basic Operations // Delete an object db.remove(webinars, node.js) // Does this key exist? db.exists(frameworks, node.js) // Give me them all db.getAll(frameworks) // But filter them too (uses MapReduce) db.getAll(frameworks, { where: { language: "javascript" }})basho
    • 24. Basic Operations // Delete an object db.remove(webinars, node.js) // Does this key exist? db.exists(frameworks, node.js) // Give me them all db.getAll(frameworks) // But filter them too (uses MapReduce) db.getAll(frameworks, { where: { language: "javascript" }}) // How many are there? db.count(frameworks)basho
    • 25. Meta Object db.save(‘bucket’, ‘key’, data, META, cb) function cb(err, data, META){ }basho
    • 26. Meta Object db.save(‘bucket’, ‘key’, data, META, cb)basho
    • 27. Meta Object db.save(‘bucket’, ‘key’, data, META, cb) • Request-time optionsbasho
    • 28. Meta Object db.save(‘bucket’, ‘key’, data, META, cb) • Request-time options •contentTypebasho
    • 29. Meta Object db.save(‘bucket’, ‘key’, data, META, cb) • Request-time options •contentType •clientIdbasho
    • 30. Meta Object db.save(‘bucket’, ‘key’, data, META, cb) • Request-time options •contentType •clientId • links, usermetabasho
    • 31. Meta Object db.save(‘bucket’, ‘key’, data, META, cb) • Request-time options •contentType •clientId • links, usermeta • quorums (r,w,dw), returnBodybasho
    • 32. Meta Object function cb(err, data, META){ }basho
    • 33. Meta Object function cb(err, data, META){ } • Response-time metadatabasho
    • 34. Meta Object function cb(err, data, META){ } • Response-time metadata • bucket, key, vclockbasho
    • 35. Meta Object function cb(err, data, META){ } • Response-time metadata • bucket, key, vclock • links, usermetabasho
    • 36. Meta Object function cb(err, data, META){ } • Response-time metadata • bucket, key, vclock • links, usermeta • lastMod, etag, statusCodebasho
    • 37. Using Metabasho
    • 38. 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)   })basho
    • 39. 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})basho
    • 40. Querying Beyond Key-Valuebasho
    • 41. Link-walkingbasho
    • 42. Link-walking // Find friends db.walk(people, sean, [[_,friend]])basho
    • 43. Link-walking // Find friends db.walk(people, sean, [[_,friend]]) // Find acquaintances of friends db.walk(people, mathias,         [[_,friend],          [people,_]])basho
    • 44. MapReducebasho
    • 45. 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);        })basho
    • 46. 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()basho
    • 47. MapReducebasho
    • 48. MapReduce // Initiate MapReduce with a key-filter db.add({ bucket: emails,          key_filters: [["ends_with", "basho.com"]] }) // Map with a phase-argument   .map({ name:Riak.mapByFields,          arg: { joined:2010-01-01 })   .run()basho
    • 49. Riak Searchbasho
    • 50. Riak Search // Turn on automatic document indexing db.enableIndex(documents)basho
    • 51. Riak Search // Turn on automatic document indexing db.enableIndex(documents) // Perform a simple search db.search(documents, title:scalable)basho
    • 52. Riak Search // Turn on automatic document indexing db.enableIndex(documents) // Perform a simple search db.search(documents, title:scalable) // Start a MapReduce query with search db.addSearch(documents, title:scalable) // From here, add map and reduce phasesbasho
    • 53. Running Testsbasho
    • 54. Test Serverbasho
    • 55. Test Server // Add test server to your tests var TestServer = require(riak-js).TestServerbasho
    • 56. Test Server // Add test server to your tests var TestServer = require(riak-js).TestServer var testServer = new TestServer({binDir: "/usr/local/bin"})basho
    • 57. Test Server // Add test server to your tests var TestServer = require(riak-js).TestServer var testServer = new TestServer({binDir: "/usr/local/bin"}) var vows = require(vows), assert = require(assert)basho
    • 58. Test Server // Add test server to your tests var TestServer = require(riak-js).TestServer var testServer = new TestServer({binDir: "/usr/local/bin"}) var vows = require(vows), assert = require(assert) suite = vows.describe("Example tests")basho
    • 59. Test Server // Add test server to your tests var TestServer = require(riak-js).TestServer var testServer = new TestServer({binDir: "/usr/local/bin"}) var vows = require(vows), assert = require(assert) suite = vows.describe("Example tests") // Bootstrap the test server suite.addBatch({   setup:{     topic: function(){       var cb = this.callback       testServer.prepare(function(){ testServer.start(cb) })     },basho
    • 60. Test Server // Add test server to your tests var TestServer = require(riak-js).TestServer var testServer = new TestServer({binDir: "/usr/local/bin"}) var vows = require(vows), assert = require(assert) suite = vows.describe("Example tests") // Bootstrap the test server suite.addBatch({   setup:{     topic: function(){       var cb = this.callback       testServer.prepare(function(){ testServer.start(cb) })     },    works: function(){      assert.isTrue(testServer.started)    } }})basho
    • 61. Test Serverbasho
    • 62. Test Server // Clear data before a test suite.addBatch({   stores data:{      topic: function(){        var cb = this.callback        testServer.clear(function(){          db.save(companies, basho, {city:"Cambridge"}, cb)        })      },      successfully: function(err, data, meta){ }   }})basho
    • 63. Test Server // Clear data before a test suite.addBatch({   stores data:{      topic: function(){        var cb = this.callback        testServer.clear(function(){          db.save(companies, basho, {city:"Cambridge"}, cb)        })      },      successfully: function(err, data, meta){ }   }}) // Shutdown the server at the end suite.addBatch({   teardown:{     topic: function() {       testServer.stop(this.callback)     },     works:function(){       assert.ok(!testServer.started)     }   }})basho
    • 64. Demo & Code https://github.com/basho/riaktantbasho
    • 65. Hosted on Joyent http://no.de Demo & Code https://github.com/basho/riaktantbasho
    • 66. Plug Interested in learning about support, consulting, or Enterprise features? Email info@basho.com or go to http://www.basho.com/ contact.php to talk with us. www.basho.combasho
    • 67. Plug Interested in learning about support, consulting, or Enterprise features? Email info@basho.com or go to http://www.basho.com/ contact.php to talk with us. www.basho.com mathias@basho.com @roidrage sean@basho.com @seancribbsbasho
    • 68. Questions?basho

    ×