Questions tagged [mysqljs]
62 questions
0
votes
1 answer
NodeJS-Express request with MySQL functions inside needs async?
I'm new to MySQL(JS) in NodeJS, I always used MongoDB. So now I'm confused because while all request with Mongoose functions inside in tutorials had async await, MySQL tutorials of the same thing is not, about 50% have and 50% not. Sometimes…

South3492
- 101
- 9
0
votes
1 answer
How to wait to pending promises to return
Today I was getting so many Promise { < pending > } and I don't know why, so i tried to console.log() a few things, and i discovered that getData() is returning before queryDatabase(), can someone explain me why, and what can I do it to fix it? I…

akkoboi
- 39
- 1
- 6
0
votes
1 answer
Trying return an array built from a foreach loop of a returned mysql query
Trying to build a more complex return of a MySQL query but the return doesn't wait for the forEach loop to complete.
export const Query = (query: string, values?: Array) => {
return new Promise>((resolve, reject) =>…

mitchell gams
- 1
- 1
0
votes
2 answers
MySQL timestamp field return empty object in API response
i've a simple table in MySQL with 2 timestamp fields:
*"...
creation timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
last_edit timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
..."*
When i try to fetch with a simple…

Ali Fumagalli
- 239
- 1
- 2
- 10
0
votes
2 answers
Node.Js mysql only excecuted for the first time
I have a problem with a node.js application that I have written, the SQL statement is only working the first time it is executed and the function after the statement never gets fired.
There are no errors when I start the application and it runs even…

Patrick Langkau
- 47
- 11
0
votes
1 answer
How to use MySQL with Vue SSR directly without REST API backend?
I would like to use MySQL as the data source when fetching for the content during server side rendering so I don't need to create an external API server for the purpose of fetching the data from the database.

zyneragetro
- 139
- 1
- 2
- 13
0
votes
0 answers
Get stored Date from MySQL without converting it into GMT format?
+----+---------+---------------------+---------+---------+
| id | user_id | date | title | seconds |
+----+---------+---------------------+---------+---------+
| 1 | 16 | 2020-05-22 23:23:55 | value | 35…

kertal
- 55
- 6
0
votes
1 answer
How to reconnect using Pool in nodejs' promise-mysql if the connection went down?
I am employing promise-mysql NodeJs library to make awaitable operations against a MySQL server.
Presently I have a simple config:
let pool = await mysql.createPool(dbConfig);
let connection = await pool.getConnection();
/// after the…

onkami
- 8,791
- 17
- 90
- 176
0
votes
1 answer
MySQL Node.js Query Ends, no Callback
I'm using mysql for node.js.
This query checks if a column has all NULL values, by checking if at least one row is not NULL.
SELECT 1 FROM `table` WHERE `column` IS NOT NULL LIMIT 1
If the column has all NULL values, this query ends in the SQL…

Amit
- 5,924
- 7
- 46
- 94
0
votes
0 answers
How to get the last inserted whole row in mysql in Nodejs
How can I get the whole just inserted data without another query, is that possible?
I know the ID is there in the response payload: data.insertId
My issue is that when I insert the values there is an auto timestamp and I need it, but I don't want to…

lito
- 3,105
- 11
- 43
- 71
0
votes
0 answers
Node.js API service with graphql query, mysql and apigee proxy gives following error: EConnRefused
I have a node.js API microservice that leverages graphql library. My API microservice connects with another node.js microservice that does a graphql mutation inside a MySql database. My api microservice is set up as a proxy in production inside of…

Roger Dodger
- 927
- 2
- 16
- 37
0
votes
1 answer
Cannot connect to mysql server programmatically
I am trying to connect to a mysql server with the mysql library. I used the following code:
const mysql = require('mysql');
const connection = mysql.createConnection({
host : 'mysql.panamath.org',
user : ,
password…

rassar
- 5,412
- 3
- 25
- 41
0
votes
1 answer
Mysql query doesn't work anymore when escaping values
I have query for adding columns to a database in my Node server:
const query = 'ALTER TABLE ' + mysql.escape(tableData[i]) + ' ADD ' + mysql.escape(attributeData[0]) + ' FLOAT DEFAULT NULL;'
If I use they query without mysql.escape() it adds the…

user3742929
- 360
- 3
- 17
0
votes
1 answer
How to create triggers using mysqljs package for nodejs?
I am trying to create a trigger for a database, using mysql package for nodejs. But I get an error saying
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near…

Subash
- 137
- 1
- 2
- 15
0
votes
2 answers
I wrapped with try-catch block but app crashed
I am trying to throw an error in the following syntex:
if(err) throw err
What I expect is to print the log by the line of "console.log(err)" instead of app crashed.
However, this occurs an error with app crashed and says
throw err; // Rethrow…

JillAndMe
- 3,989
- 4
- 30
- 57