Skip to content

Instantly share code, notes, and snippets.

@Prinzhorn
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Prinzhorn/8e36920582e047c4f5b3 to your computer and use it in GitHub Desktop.
Save Prinzhorn/8e36920582e047c4f5b3 to your computer and use it in GitHub Desktop.
RethinkDB with Express
var express = require('express');
var r = require('rethinkdb');
var app = express();
r.connect(config.rethinkdb, function(err, conn) {
if(err) {
return handleError(res, err);
}
app.db = function(query, callback) {
query.run(conn, callback);
};
});
//Later use it like this
req.app.db(r.table('todos').get(todo.id), function(err, result) {
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment