O'Reilly logo

Mastering RethinkDB by Shahid Shaikh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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({ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required