Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Realtime Apps with RethinkDB and Node.JS

Avatar for MattCollins84 MattCollins84
September 14, 2016

Realtime Apps with RethinkDB and Node.JS

Taking a look at building Realtime Apps with RethinkDB and Node.js

Avatar for MattCollins84

MattCollins84

September 14, 2016

Other Decks in Technology

Transcript

  1. :(

  2. Open Source NoSQL DB JSON document store Distributed Really nice

    admin UI Designed for building realtime apps! Own query language - ReQL
  3. RethinkDB Application cursor.next() cursor.each( (err, item) => { … }

    ) cursor.toArray( (err, results) => { … } )
  4. r.db("nottsjs") .table("questions") [ { id: "cad7-470d-b8d0-e89900bcda0d", question: "What is your

    favourite colour?" score: 10 }, { id: "d5c9-d104-0d31-1c2f199b", question: "Where were you born?" score: 5 } ]
  5. I/O

  6. Querying RethinkDB const r = require("rethinkdb"); r.connect((err, conn) => {

    r.table("questions").run(conn,(err, cursor)=> { cursor.toArray((err, results) => { conn.close(); console.log(results); }) }) })
  7. Querying RethinkDB const r = require("rethinkdb"); r.connect((err, conn) => {

    r.table("questions").run(conn,(err, cursor)=> { cursor.toArray((err, results) => { conn.close(); console.log(results); }) }) })
  8. Querying RethinkDB const r = require("rethinkdb"); r.connect((err, conn) => {

    r.table("questions").run(conn,(err, cursor)=> { cursor.toArray((err, results) => { conn.close(); console.log(results); }) }) })
  9. Querying RethinkDB const r = require("rethinkdb"); r.connect((err, conn) => {

    r.table("questions").run(conn,(err, cursor)=> { cursor.toArray((err, results) => { conn.close(); console.log(results); }) }) })
  10. Changefeeds are similar... const r = require("rethinkdb"); r.connect((err, conn) =>

    { r.table("questions").changes() .run(conn,(err, cursor)=> { cursor.each((err, event) => { console.log(event) }) }) })
  11. Changefeeds are similar... const r = require("rethinkdb"); r.connect((err, conn) =>

    { r.table("questions").changes() .run(conn,(err, cursor)=> { cursor.each((err, event) => { console.log(event) }) }) })
  12. Changefeeds are similar... const r = require("rethinkdb"); r.connect((err, conn) =>

    { r.table("questions").changes() .run(conn,(err, cursor)=> { cursor.each((err, event) => { console.log(event) }) }) })
  13. App .changes() io.emit('new', q) RethinkDB App App App App io.emit('new',

    q) io.emit('new', q) io.emit('new', q) io.emit('new', q)
  14. r.table("questions").changes() .run(conn, (err,cursor) => { cursor.each((err, e) => { if

    (!e.old_val && e.new_val) { io.emit('new-q', e.new_val) } }); });