3d-interface/server/posts/previous-next-clicked/index.js

34 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

var pg = require('pg');
var secret = require('../../private');
2015-07-03 13:27:05 +02:00
var Log = require('../../lib/NodeLog.js');
module.exports.index = function(req, res) {
pg.connect(secret.url, function(err, client, release) {
client.query(
"INSERT INTO previousnextclicked(exp_id, previousnext, time, camera)" +
"VALUES($1, $2, to_timestamp($3), ROW(ROW($4,$5,$6), ROW($7,$8,$9)));" ,
[
req.session.expId,
req.body.previous ? 'p' : 'n',
req.body.time,
req.body.camera.position.x,
req.body.camera.position.y,
req.body.camera.position.z,
req.body.camera.target.x,
req.body.camera.target.y,
req.body.camera.target.z
],
function(err, result) {
2015-07-01 11:31:44 +02:00
if (err !== null)
2015-07-09 15:04:55 +02:00
Log.dberror(err + ' in previousnext');
release();
}
);
});
res.setHeader('Content-Type', 'text/html');
res.send("");
};