Hi,
This post shows just how to combine NodeJS with MYSQL in a simple way.
You can run whatever queries you want using the query async method (await query(sql, []))
Just don't forget the prepared statements if you have user input.
How to do it is another part of the SQL.
If you want to make a query that depends on another query,
all you need to do is write the first query with await query-> get the result,
Then use it on another query.
async-await it's a new feature from ES8, and it's like the newest version of Promise.
promise.then(data=>{console.log(data);});
Is like:
constdata=awaitpromise();console.log(data);
The line below the await promise() is like using the .then() method.
You can read more about it to understand how to use it.
The utils.js file is just a file to hold the common functions that we can reuse over and over; that's all.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi,
This post shows just how to combine NodeJS with MYSQL in a simple way.
You can run whatever queries you want using the query async method (await query(sql, []))
Just don't forget the prepared statements if you have user input.
How to do it is another part of the SQL.
If you want to make a query that depends on another query,
all you need to do is write the first query with await query-> get the result,
Then use it on another query.
async-await it's a new feature from ES8, and it's like the newest version of Promise.
Is like:
The line below the await promise() is like using the .then() method.
You can read more about it to understand how to use it.
The utils.js file is just a file to hold the common functions that we can reuse over and over; that's all.