WIP -- handle state change requests

This commit is contained in:
Josh Harvey 2016-02-08 16:02:03 +02:00
parent 2400504827
commit 7c15ce0ae8
3 changed files with 32 additions and 2 deletions

View file

@ -1,4 +1,3 @@
/* @flow weak */
'use strict';
// TODO: Consider using serializable transactions for true ACID
@ -514,6 +513,19 @@ exports.cartridgeCounts = function cartridgeCounts(session, cb) {
});
};
exports.machineEvent = function machineEvent(rec, cb) {
connect(function(cerr, client, done) {
if (cerr) return cb(cerr);
var sql = 'insert into machine_events (id, device_fingerprint, event_type, note, device_time) ' +
'VALUES (?, ?, ?, ?, ?)';
var values = [rec.id, rec.fingerprint, rec.eventType, rec.note, rec.deviceTime]
query(client, sql, values, function(err, results) {
done();
return cb(err, results);
});
});
};
/*
exports.init('postgres://lamassu:lamassu@localhost/lamassu');
connect(function(err, client, done) {