Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- var Gently, _a, mysql;
- mysql = require('mysql');
- Gently = require('gently');
- exports.Database = (function() {
- _a = function() {
- var Client;
- Client = mysql.Client;
- this.client = new Client();
- this.gently = new Gently();
- return this;
- };
- _a.prototype.connect = function(host, user, password, database) {
- this.client.user = "root";
- this.client.password = "root";
- this.client.host = "localhost";
- this.client.database = "filsh4";
- this.client.connect();
- if (this.client) {
- console.log(("MySQL connection to " + (host) + " established"));
- };
- return null;
- };
- _a.prototype.disconnect = function() {
- this.client.end();
- return null;
- };
- _a.prototype.getConfig = function(callback) {
- this.client.query('SELECT * FROM config', function(err, results, fields) {
- var _b, _c, _d, config, result;
- console.log(results);
- config = {};
- if ((err)) {
- throw err;
- }
- _c = results;
- for (_b = 0, _d = _c.length; _b < _d; _b++) {
- result = _c[_b];
- config[result.variable] = result.value;
- }
- callback(config);
- return null;
- });
- return null;
- };
- _a.prototype.getServerInfoById = function(id, callback) {
- // # The following query causes this error message:
- // #
- // #/Users/sascha/.node_libraries/mysql/query.js:42
- // # field = this._fields[0];
- // # ^
- // # TypeError: Cannot read property '0' of undefined
- // # at Query._handlePacket (/Users/sascha/.node_libraries/mysql/query.js:42:31)
- // # at Client._handlePacket (/Users/sascha/.node_libraries/mysql/client.js:194:14)
- // # at Parser.<anonymous> (/Users/sascha/.node_libraries/mysql/client.js:56:14)
- // # at Parser.emit (events:26:26)
- // # at Parser.write (/Users/sascha/.node_libraries/mysql/parser.js:479:16)
- // # at Stream.<anonymous> (/Users/sascha/.node_libraries/mysql/client.js:51:16)
- // # at Stream.emit (events:26:26)
- // # at IOWatcher.callback (net:512:16)
- // # at node.js:773:9
- this.client.query('SELECT * FROM `servers`', function(err, results, fields) {
- var result, server;
- console.log(results);
- if ((err)) {
- throw err;
- }
- result = results.first;
- server = result;
- callback(server);
- return null;
- });
- return null;
- };
- return _a;
- })();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement