Created
October 26, 2016 21:05
-
-
Save anonymous/97c0086dd94a2ed6871e3e3fa552ff5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('bluebird'); | |
var rdb = Promise.promisify(require('rethinkdb')); | |
module.exports = function(config) { | |
return { | |
connectToDb: function(){ | |
return Promise.try( | |
function(){ | |
return rdb.connect(config); | |
} | |
) | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('bluebird'); | |
var rdb = Promise.promisify(require('rethinkdb')); | |
var config = { host: "localhost", port: 28015 } | |
var RethinkDbConnection = require('./lib/RethinkDbConnection')(config).connectToDb(); | |
var tableName = "testdb"; // <------ just for testing | |
var createTable = function(tableName){ | |
RethinkDbConnection.then( (connectionResult) => { | |
rdb.db('test').tableCreate(tableName).run(connectionResult).then( (tableCreationResult) => { | |
console.log(JSON.stringify(tableCreationResult, null, 2)); | |
}); | |
}); | |
} | |
createTable(tableName); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment