-
-
Save joepie91/dd1df4607b0c3c0ae9ab270995b3405e 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(() => { | |
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 = 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){ | |
return Promise.try(() => { | |
return RethinkDbConnection; | |
}).then((connectionResult) => { | |
return 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