├── .gitignore ├── README.md ├── admin-proxy.js ├── package.json ├── rethinkdb_data ├── 39bd36b1-293c-478a-96fa-ba68736d9f22 ├── auth_metadata ├── log_file └── metadata ├── server.js └── test └── test.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # learn-rethinkdb 2 | 3 | Learn how to use RethinkDB to power your next real-time app! 4 | 5 | > RethinkDB is to MongoDB as Node.js is to PHP; 6 | prepare to have your mind *blown*! 7 | http://www.rethinkdb.com/docs/rethinkdb-vs-mongodb/ 8 | 9 | ## What? 10 | 11 | + RethinkDB intro: https://youtu.be/cnpSi9qI02E 12 | 13 | 14 | ## How? 15 | 16 | ### Installation 17 | 18 | #### Mac 19 | 20 | If you are using [*Homebrew*](http://brew.sh/) on your Mac you can install RethinkDB using the simple command in the terminal: 21 | 22 | ``` 23 | brew update && brew install rethinkdb 24 | ``` 25 | 26 | This will install all of RethinkDB's dependencies, expect to see: 27 | 28 | ![learn-rethinkdb-brew-install](https://cloud.githubusercontent.com/assets/194400/8251410/40d32f96-1674-11e5-8702-f01637d3f6a9.png) 29 | 30 | Once it installation completes (*with brew*) you should see: 31 | 32 | ![learn-rethinkdb-brew-install-complete](https://cloud.githubusercontent.com/assets/194400/8251444/7e09f8ea-1674-11e5-80e0-6ce53313359f.png) 33 | 34 | In case you missed it, these are the suggested commands to 35 | ***ensure RethinkDB starts when your Mac (re)boots***: 36 | ```sh 37 | ln -sfv /usr/local/opt/rethinkdb/*.plist ~/Library/LaunchAgents 38 | launchctl load ~/Library/LaunchAgents/homebrew.mxcl.rethinkdb.plist 39 | ``` 40 | 41 | > Detailed stop/start instructions: http://rethinkdb.com/docs/start-on-startup/ 42 | 43 | ### Quick Start 44 | 45 | Once you have *installed RethinkDB*, read the Quick Start: 46 | http://www.rethinkdb.com/docs/quickstart/ 47 | 48 | #### Start the RethinkDB Server 49 | 50 | In your terminal, start the server with the command: 51 | ```sh 52 | rethinkdb 53 | ``` 54 | 55 | You should see (*something similar to this*): 56 | ![learn-rethinkdb-start-server](https://cloud.githubusercontent.com/assets/194400/8251351/c8aeafb8-1673-11e5-8ec2-d7a46fa3d7ad.png) 57 | 58 | Check it worked by visiting: http://127.0.0.1:8080/ 59 | You should expect to see: 60 | 61 | ![rethinkdb-admin-interface](https://cloud.githubusercontent.com/assets/194400/8252011/5a749d86-1679-11e5-925e-a5c6cf61bdf2.png) 62 | 63 | 64 | ## Useful Links 65 | 66 | + Advancing the realtime web (*the _Why_? behind RethinkDB*): 67 | http://www.rethinkdb.com/blog/realtime-web/ 68 | + Installation: http://www.rethinkdb.com/docs/install/ 69 | + Quick Start: http://www.rethinkdb.com/docs/quickstart/ 70 | + Building **Realtime Web Applications** Just Got ***Easy***: https://www.youtube.com/watch?v=ZwyjDiikNKk 71 | + (_"[its not all rainbows and butterflies](https://youtu.be/nIjVuRTm-dc?t=1m46s)" ... be **aware** of the_) ***Limitations***: http://rethinkdb.com/limitations/ 72 | + Intro to **Platzi** (*why/how they are using RethinkDB*): https://www.youtube.com/watch?v=Nb_UzRYDB40 73 | + Platzi **RethinkDB Course**: https://courses.platzi.com/courses/rethinkdb-databases/ 74 | + Build a _**realtime RethinkDB cluster monitoring**_ app with live graphs 75 | https://www.youtube.com/watch?v=dhb63boH8E8 76 | + Nodejs driver (module): http://www.rethinkdb.com/docs/install-drivers/javascript/ 77 | -------------------------------------------------------------------------------- /admin-proxy.js: -------------------------------------------------------------------------------- 1 | var Hapi = require('hapi'); 2 | var server = new Hapi.Server(); 3 | var PORT = Number(process.argv[2] || 5000) 4 | server.connection({ port: PORT }); 5 | server.route({ 6 | path:'/{p*}', 7 | method: 'GET', 8 | handler: function (request, reply) { 9 | reply.proxy({ 10 | host: '127.0.0.1', 11 | port: 8080, 12 | protocol: 'http', 13 | passThrough: true 14 | }); 15 | } 16 | }); 17 | 18 | server.start(); 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "learn-rethinkdb", 3 | "version": "1.0.0", 4 | "description": "Learn how to use RethinkDB to power your next real-time app!", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "node ./test/*", 8 | "admin": "./node_modules/.bin/nodemon admin-proxy.js" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/nelsonic/learn-rethinkdb.git" 13 | }, 14 | "keywords": [ 15 | "rethinkdb", 16 | "tutorial", 17 | "from-scratch" 18 | ], 19 | "author": "nelsonic", 20 | "license": "ISC", 21 | "bugs": { 22 | "url": "https://github.com/nelsonic/learn-rethinkdb/issues" 23 | }, 24 | "homepage": "https://github.com/nelsonic/learn-rethinkdb#readme", 25 | "dependencies": { 26 | "hapi": "^8.6.1" 27 | }, 28 | "devDependencies": { 29 | "nodemon": "^1.3.7" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /rethinkdb_data/39bd36b1-293c-478a-96fa-ba68736d9f22: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dwyl/learn-rethinkdb/6d86cdd3dcd2f92cad903690cd43144f931dd33c/rethinkdb_data/39bd36b1-293c-478a-96fa-ba68736d9f22 -------------------------------------------------------------------------------- /rethinkdb_data/auth_metadata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dwyl/learn-rethinkdb/6d86cdd3dcd2f92cad903690cd43144f931dd33c/rethinkdb_data/auth_metadata -------------------------------------------------------------------------------- /rethinkdb_data/log_file: -------------------------------------------------------------------------------- 1 | 2015-06-19T11:06:04.748625000 0.087960s notice: Recursively removing directory /Users/n/code/learn-rethinkdb/rethinkdb_data/tmp 2 | 2015-06-19T11:06:04.751135000 0.090472s notice: Initializing directory /Users/n/code/learn-rethinkdb/rethinkdb_data 3 | 2015-06-19T11:06:04.751317000 0.090649s info: Creating a default database for your convenience. (This is because you ran 'rethinkdb' without 'create', 'serve', or '--join', and the directory '/Users/n/code/learn-rethinkdb/rethinkdb_data' did not already exist or is empty.) 4 | 2015-06-19T11:06:04.751343000 0.090675s notice: Running rethinkdb 2.0.3 (CLANG 6.1.0 (clang-602.0.53))... 5 | 2015-06-19T11:06:04.768145000 0.107479s notice: Running on Darwin 14.3.0 x86_64 6 | 2015-06-19T11:06:04.768198000 0.107530s notice: Loading data from directory /Users/n/code/learn-rethinkdb/rethinkdb_data 7 | 2015-06-19T11:06:05.010045000 0.349377s info: Automatically using cache size of 100 MB 8 | 2015-06-19T11:06:05.010056000 0.349388s warn: Cache size is very low and may impact performance. 9 | 2015-06-19T11:06:05.011366000 0.350698s notice: Listening for intracluster connections on port 29015 10 | 2015-06-19T11:06:05.014413000 0.353745s notice: Listening for client driver connections on port 28015 11 | 2015-06-19T11:06:05.014611000 0.353943s notice: Listening for administrative HTTP connections on port 8080 12 | 2015-06-19T11:06:05.014613000 0.353945s notice: Listening on addresses: 127.0.0.1, ::1 13 | 2015-06-19T11:06:05.014617000 0.353948s notice: To fully expose RethinkDB on the network, bind to all addresses by running rethinkdb with the `--bind all` command line option. 14 | 2015-06-19T11:06:05.014620000 0.353951s notice: Server ready, "local_7ob" 4e945df0-f4bc-40f8-bd1f-2901af4ef1f9 15 | 2015-06-29T13:56:57.110132000 0.005439s notice: Recursively removing directory /Users/n/code/learn-rethinkdb/rethinkdb_data/tmp 16 | 2015-06-29T13:56:57.111552000 0.006861s notice: Running rethinkdb 2.0.3 (CLANG 6.1.0 (clang-602.0.53))... 17 | 2015-06-29T13:56:57.116609000 0.011916s notice: Running on Darwin 14.3.0 x86_64 18 | 2015-06-29T13:56:57.116649000 0.011955s notice: Loading data from directory /Users/n/code/learn-rethinkdb/rethinkdb_data 19 | 2015-06-29T13:56:57.198946000 0.094253s info: Automatically using cache size of 100 MB 20 | 2015-06-29T13:56:57.199036000 0.094342s warn: Cache size does not leave much memory for server and query overhead (available memory: 1108 MB). 21 | 2015-06-29T13:56:57.199041000 0.094347s warn: Cache size is very low and may impact performance. 22 | 2015-06-29T13:56:57.199911000 0.095218s error: TCP socket creation failed for port 29015: Address already in use. 23 | -------------------------------------------------------------------------------- /rethinkdb_data/metadata: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dwyl/learn-rethinkdb/6d86cdd3dcd2f92cad903690cd43144f931dd33c/rethinkdb_data/metadata -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | r = require('rethinkdb') 2 | r.connect({ host: 'localhost', port: 28015 }, function(err, conn) { 3 | if(err) throw err; 4 | r.db('test').tableCreate('tv_shows').run(conn, function(err, res) { 5 | if(err) throw err; 6 | console.log(res); 7 | r.table('tv_shows').insert({ name: 'Star Trek TNG' }).run(conn, function(err, res) 8 | { 9 | if(err) throw err; 10 | console.log(res); 11 | }); 12 | }); 13 | }); 14 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dwyl/learn-rethinkdb/6d86cdd3dcd2f92cad903690cd43144f931dd33c/test/test.js --------------------------------------------------------------------------------