Integrating RethinkDB with Node.js
We have a basic skeleton of controllers in place and now we need to write some model functions to deal with the RethinkDB database.
One of the basic functions we need is to perform the connectivity to the database and RethinkDB instance.
The reason why we need two functions is because we are going to create the database from the application code. To do that, we need a database instance connection instead of a database connection.
Here is the function to do both of the operations:
"use strict"; var rethinkdb = require('rethinkdb'); connectToRethinkDbServer(callback) { rethinkdb.connect({ host : 'localhost', port : 28015 }, function(err,connection) { callback(err,connection); }); } connectToDb(callback) { rethinkdb.connect({ ...
Get Mastering RethinkDB now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.