cena a casa di cek
This commit is contained in:
parent
57b3579bab
commit
89019f168c
6 changed files with 9 additions and 4 deletions
11
dbHandler.js
11
dbHandler.js
|
@ -1,6 +1,7 @@
|
||||||
const config = require('config');
|
const config = require('config');
|
||||||
const mysql = require('mysql');
|
const mysql = require('mysql');
|
||||||
|
const dateToUtc = require('./utils.js')
|
||||||
|
|
||||||
const pool = mysql.createPool({
|
const pool = mysql.createPool({
|
||||||
host: config.get('db.host'),
|
host: config.get('db.host'),
|
||||||
user: config.get('db.user'),
|
user: config.get('db.user'),
|
||||||
|
@ -10,7 +11,11 @@ const pool = mysql.createPool({
|
||||||
|
|
||||||
function addMarker(marker) {
|
function addMarker(marker) {
|
||||||
let insertQuery = 'INSERT INTO markers VALUES (?,?,?,POINT(?,?),?)';
|
let insertQuery = 'INSERT INTO markers VALUES (?,?,?,POINT(?,?),?)';
|
||||||
let query = mysql.format(insertQuery, [marker.name, marker.description, marker.filename, marker.long, marker.lat, new Date()]);
|
const date = new Date().toISOString()
|
||||||
|
const datePart = date.slice(0, 10); // '2024-09-06'
|
||||||
|
const timePart = date.slice(11, 19); // '21:33:44'
|
||||||
|
const formattedDate = `${datePart} ${timePart}`
|
||||||
|
let query = mysql.format(insertQuery, [marker.name, marker.dTIMESTAMPescription, marker.filename, marker.long, marker.lat, formattedDate]);
|
||||||
pool.query(query, (err, response) => {
|
pool.query(query, (err, response) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
@ -36,7 +41,7 @@ function getUpdatedMarkers(fromDate, callback) {
|
||||||
pool.getConnection((err, connection) => {
|
pool.getConnection((err, connection) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
let selectQuery = 'SELECT * FROM markers mrk WHERE mrk.ts >= ?';
|
let selectQuery = 'SELECT * FROM markers mrk WHERE mrk.ts >= ?';
|
||||||
let query = mysql.format(selectQuery, [new Date(parseInt(fromDate))])
|
let query = mysql.format(selectQuery, fromDate)
|
||||||
connection.query(query, (err, rows) => {
|
connection.query(query, (err, rows) => {
|
||||||
connection.release(); // return the connection to pool
|
connection.release(); // return the connection to pool
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
|
|
@ -8,5 +8,5 @@ CREATE TABLE ruscomap.markers (
|
||||||
description VARCHAR(1024),
|
description VARCHAR(1024),
|
||||||
filename VARCHAR(256) NOT NULL,
|
filename VARCHAR(256) NOT NULL,
|
||||||
coordinate POINT NOT NULL,
|
coordinate POINT NOT NULL,
|
||||||
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP2
|
||||||
);
|
);
|
0
script/AggiornaRuscoMap.sh
Normal file → Executable file
0
script/AggiornaRuscoMap.sh
Normal file → Executable file
0
script/cerca_rusco.sh
Normal file → Executable file
0
script/cerca_rusco.sh
Normal file → Executable file
0
script/delete_rusco.sh
Normal file → Executable file
0
script/delete_rusco.sh
Normal file → Executable file
0
utils.js
Normal file
0
utils.js
Normal file
Loading…
Reference in a new issue