mirror of
https://gitlab.silvrtree.co.uk/martind2000/mdot_server.git
synced 2025-01-27 12:56:16 +00:00
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
'use strict';
|
|
var logger = require('log4js').getLogger();
|
|
|
|
module.exports = function(db) {
|
|
var module = {};
|
|
|
|
module.sqlInsertMeeting = function(data) {
|
|
let _data = data;
|
|
|
|
logger.debug('sqlInsertMeeting', _data.locationid, _data.timestamp);
|
|
return new Promise(function(resolve, reject) {
|
|
db.none('INSERT into meeting(locationid, logged, count, start, "end") Values( ${locationid}, ${timestamp}, ${count}, ${start}, ${end})', _data)
|
|
.then(()=> {
|
|
return resolve('ok');
|
|
})
|
|
.catch((err)=> {
|
|
return reject(err);
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
module.addNewMeeting = function(data) {
|
|
logger.debug('addNewMeeting');
|
|
var self = this;
|
|
return new Promise((resolve, reject) => {
|
|
|
|
let _data = {};
|
|
_data.timestamp = new Date();
|
|
_data.locationid = data.locationid;
|
|
_data.count = data.count;
|
|
_data.start = new Date(data.start);
|
|
_data.end = new Date(data.end);
|
|
|
|
console.log('_data', _data);
|
|
|
|
self.sqlInsertMeeting(_data)
|
|
.then((d)=> {
|
|
logger.debug('Postgres returns', d);
|
|
return resolve({reply: 'track inserted'});
|
|
})
|
|
.catch((err)=> {
|
|
return reject(err);
|
|
});
|
|
});
|
|
};
|
|
|
|
|
|
return module;
|
|
};
|
|
|