diff options
| author | Adam Soltys <[email protected]> | 2012-11-12 17:31:37 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2012-11-12 17:31:40 -0800 |
| commit | c3d599a58a6d5a86527478b4b712b00134d0547e (patch) | |
| tree | f4716b141c2b91b97715a442120daa922873bee0 /app.coffee | |
| parent | 95d18698d19102da315091aee16f49809f96e9ab (diff) | |
| download | coinos-server-c3d599a58a6d5a86527478b4b712b00134d0547e.tar.gz coinos-server-c3d599a58a6d5a86527478b4b712b00134d0547e.zip | |
Switch from mysql to redis
Diffstat (limited to 'app.coffee')
| -rw-r--r-- | app.coffee | 36 |
1 files changed, 9 insertions, 27 deletions
@@ -24,15 +24,11 @@ app.get('/report', (req, res) -> res.render('report', js: (-> global.js), css: (-> global.css)) ) -app.get('/client/:login', (req, res) -> - connection = require('mysql').createConnection(config.database) - - connection.connect() - connection.query("SELECT name, address, commission, logo FROM users WHERE login = ?", - [req.params.login], (err, rows) -> - res.write(JSON.stringify(rows)) - connection.end() - res.end() +app.get('/client/:client', (req, res) -> + db = require("redis").createClient() + db.hgetall(req.params.client, (err, obj) -> + res.write(JSON.stringify(obj)) + res.end() ) ) @@ -65,24 +61,10 @@ app.get('/ticker', (req, res) -> ) app.post('/create', (req, res) -> - connection = require('mysql').createConnection(config.database) - - connection.connect() - connection.query(""" - INSERT INTO users - (login, name, address, commission) - VALUES - (?, ?, ?, ?) - """, - [ - req.body.login, - req.body.name, - req.body.address, - req.body.commission - ], (err, rows) -> - connection.end() - res.writeHead(302, 'Location': '/' + req.body.login) - res.end() + db = require("redis").createClient() + db.hmset(req.body.login, req.body, -> + res.writeHead(302, 'Location': '/' + req.body.login) + res.end() ) ) |
