Do I have to use kallbaqi or promises when working with the mysql database?

Hello. This is a question about performance and odnopotochnitsa in Nodejs which I understand poorly))

I have the simplest api with the mysql module.

The script client accesses the api -> a request is made to the database -> data given to the client in json.


- Do I need to wrap the query to the database in the async/await (or other variant of an asynchronous request) in the api (NOT client)?

And if so - why? -)

Thanks in advance.
March 23rd 20 at 19:42
3 answers
March 23rd 20 at 19:44
because otherwise, because of their odnopotochnitsa, Noda will fall into a stupor and will be engaged in processing only this client, and the rest will patiently wait for their turn (if a timeout will not happen before).
there are different ways of solving such plugging, but there is one simple rule - no blocking operations.
March 23rd 20 at 19:46
I googled the answer))

A kind person took the trouble to describe the problem with code examples.

Respect and uvazhuha
March 23rd 20 at 19:48
Answer should be located in the base of the tongue and nodes and only then start writing code. Now other answers are not important, the very essence nodes you are not clear, hence indirect questions.
All right, I do not really understand the difference node from Apache+php, so try to practice to understand

the theory of course read it, but there is little that is clear - Beryl66 commented on March 23rd 20 at 19:51
@Beryl66, read until it's clear ) what else is there to say - kaleb commented on March 23rd 20 at 19:54
@kaleb, so-so Board ) - Beryl66 commented on March 23rd 20 at 19:57
@Beryl66, as a reaction to the Council
your question is born of fundamental ignorance, which is the base of genociding on the gcd, but it's certainly important enough and useful, important for you to hear if you can do all simultaneously. Okay, the answer is no, not, nod it's not about synchronous. - kaleb commented on March 23rd 20 at 20:00

Find more questions by tags Node.js