index.js 636 B

123456789101112131415161718192021222324252627
  1. var r = require('rethinkdb');
  2. require('rethinkdb-init')(r);
  3. r.connections = [];
  4. //Creates new connection
  5. r.getNewConnection = function () {
  6. return r.connect({host: 'localhost', port: 28015, db: 'musare'}).then(function (conn) {
  7. conn.use("musare");
  8. r.connections.push(conn);
  9. return conn;
  10. });
  11. };
  12. //Sets up the tables for the database
  13. r.init({host: 'localhost', port: 28015, db: 'musare'}, [
  14. {
  15. name: 'users',
  16. indexes: ['username', 'usernameL', 'email']
  17. }
  18. ]).then(function (conn) {
  19. r.conn = conn;
  20. r.connections.push(conn);
  21. r.conn.use("musare");
  22. });
  23. module.exports = r;