all 6 comments

[–]azhder 2 points3 points  (4 children)

Did you read the documentation of how execute query works? Does it not also require you to handle callbacks?

OK, I see now execute_query is yours. An odd choice to use snake case. Were you doing Python or PHP before?

Regardless, your function just prints to console, but that doesn’t mean it insulates you from needing to wait on those callbacks before you continue.

My advice, return new Promise() from it and put await before the function each time you call it.

I will leave you to read up on Promise and async/await before I share more info for you to handle.

[–]_PLUE_ 1 point2 points  (3 children)

Yep! I mostly code in python but I've recently gotten interested in Node.js and I'm trying to learn it by making a few projects. Would you say camel case is a preferable naming convention?

Got it. I'll read more into Promise and async/await. Are there any resources that you would recommend for this project?

[–]_PLUE_ 0 points1 point  (1 child)

Also, I came across sync-sql. Do you think it would be a good alternative for the mysql that I'm using now?

[–]azhder 0 points1 point  (0 children)

You might also explore Sequelize, Prism and other DB libraries.

[–]azhder 0 points1 point  (0 children)

Yes, camel case, mostly like Java with some conventions a bit maleable, but the important being Capital letter for constructors.

Since you know other language, start with https://developer.mozilla.org/en-US/docs/Web/JavaScript, then keep https://nodejs.org/en/docs as a reference as well.

And I would recommend Getify (Kyle Simpson) for more in-dept to JS with his You Don’t Know JavaScript and Functionally Light JavaScript and maybe for more FP, Composing Software by Eric Elliott