Добавил еще ведущие нули к миллисекундам, если кому-то еще когда-то этот код понадобится
log = function (text, color, define){ var id, time, thread, logHtml, textLog; define = (typeof define == 'string') ? define.split(/[\s,.|:;]+/g) : define; if(typeof define === 'object' && define !== null){ if(Array.isArray(define)){ id = define.indexOf('id') > -1; time = define.indexOf('time') > -1; thread = define.indexOf('thread') > -1; } else{ id = define.id == true; time = define.time == true; thread = define.thread == true; } } else id = time = thread = true; id = id ? '<a href="action://action' + ScriptWorker.GetCurrentAction() + '" style="color:gray;">[' + ScriptWorker.GetCurrentAction() + ']</a>' : ''; time = time ? ' ' + getTime() : ''; thread = thread ? ' Поток №' + thread_number() : ''; logHtml = (id || time || thread) ? id + '<span style="color: white">' + time + thread + ' : </span>' : ''; logHtml += '<span style="color:' + (color ? color : 'white') + '">' + text + '</span>'; textLog = '[' + ScriptWorker.GetCurrentAction() + ']' + time + thread + ' : ' + text function getTime(){ var checkTime = function(i){ return (i < 10) ? "0" + i : i; }; var checkMilliSeconds = function(ms){ if (ms < 10) { return "00" + ms; } else if (ms < 100) { return "0" + ms; } else { return ms; } }; var d = new Date(); var hh = checkTime(d.getHours()); var mm = checkTime(d.getMinutes()); var ss = checkTime(d.getSeconds()); var ms = checkMilliSeconds(d.getMilliseconds()); return '[' + hh + ':' + mm + ':' + ss + '.' + ms + ']'; }; Logger.WriteHtml(logHtml, textLog); }Переменная в node.js \ mysql
-
const mysql = require("mysql2"); const pool = mysql.createPool({ connectionLimit: 5, host: [[HOST_BD]], user: [[NAME_USER_BD]], database: [[NAME_BD]], password: [[PASS_BD]] }); pool.query("UPDATE `api` SET `api_zn`= [[DATE]] WHERE id=1", function(err, results) { });При добавлении переменной date, вылазит следующая ошибка:
Не удалось обновить:
C:\Users\Administrator\AppData\Roaming\BrowserAutomationStudio\apps\23.1.1\e\471c.XivI\distr\lib\custom\snrq0zmsar.js:17
pool.query("UPDATEapiSETapi_zn= BAS_VARS["DATE"] WHERE id=1", function(err, results) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^SyntaxError: missing ) after argument list
at wrapSafe (internal/modules/cjs/loader.js:1053:16)
at Module._compile (internal/modules/cjs/loader.js:1101:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at C:\Users\Administrator\AppData\Roaming\BrowserAutomationStudio\apps\23.1.1\e\471c.XivI\distr\lib\internal\custom.js:11:38
at Array.forEach (<anonymous>)
at module.exports.Init (C:\Users\Administrator\AppData\Roaming\BrowserAutomationStudio\apps\23.1.1\e\471c.XivI\distr\lib\internal\custom.js:10:56)Что я делаю не так?
-