Node.js Synchronous queries with MySQL

前端 未结 6 1972
走了就别回头了
走了就别回头了 2021-01-01 23:23

I\'m working on creating a user registration system for a website that I am working on but I am running into a few issues.

I\'m trying to stay away from having to ne

6条回答
  •  -上瘾入骨i
    2021-01-01 23:48

    As jfriend00 said above, if you're going to develop in node.js, then you MUST become comfortable with writing async code.

    "chained promises" is probably your best bet:

    • https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then

    • http://html5hive.org/node-js-quickies-working-with-mysql/

    ADDENDUM:

    This tutorial illustrates promise chaining with node.js SQL queries. It also discusses how you can use Q and/or Step to simplify your code:

    • http://code.tutsplus.com/tutorials/managing-the-asynchronous-nature-of-nodejs--net-36183

提交回复
热议问题