Corrected database

This commit is contained in:
Thomas FORGIONE
2015-08-25 09:25:45 +02:00
parent 82f7a7268a
commit 5f3b2e1862
10 changed files with 29 additions and 50 deletions

View File

@@ -1,32 +0,0 @@
var pg = require('pg');
var secret = require('../../private');
var Log = require('../../lib/NodeLog.js');
function insertCoinId(client, release, exp_id, coin_ids) {
if (coin_ids.length > 0) {
client.query(
'INSERT INTO Coin(exp_id, coin_id) VALUES ($1, $2);',
[exp_id,coin_ids.shift()],
function(err, result) {
if (err !== null)
Log.dberror(err + ' coin-id');
if (coin_ids.length === 0)
release();
else
insertCoinId(client, release, exp_id, coin_ids);
}
);
}
}
module.exports.index = function(req, res) {
pg.connect(secret.url, function(err, client, release) {
insertCoinId(client, release, req.session.exp_id, req.body.indices);
});
res.setHeader('Content-Type', 'text/html');
res.send("");
};

View File

@@ -1,3 +0,0 @@
module.exports = {
'/posts/coin-id': 'index'
};