1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/unleash-server/lib/eventDb.js
Ivar Conradi Østhus 826f9d56e2 #18 storing events when they are created.
Also introduced mockery to mock db-access. Here we probably
need better modularisation and/or better dependecy management
(injecting of deps?).
2020-02-20 08:30:09 +01:00

19 lines
469 B
JavaScript

var Promise = require('bluebird'),
dbPool = require('./dbPool');
function storeEvent(event) {
var sql = 'INSERT INTO events(type, created_by, data) VALUES ($1, $2, $3)';
var params = [event.type, event.createdBy, event.data];
return new Promise(function (resolve, reject) {
dbPool.query(sql, params, function (err) {
if (err) {reject(err);}
resolve();
});
});
}
module.exports = {
store: storeEvent
};