Cov txheej txheem:

Yuav ua li cas kuv khiav ib node js lus nug hauv mysql?
Yuav ua li cas kuv khiav ib node js lus nug hauv mysql?

Video: Yuav ua li cas kuv khiav ib node js lus nug hauv mysql?

Video: Yuav ua li cas kuv khiav ib node js lus nug hauv mysql?
Video: Merging PDFs with Python! 2024, Kaum ib hlis
Anonim

Nov yog yuav ua li cas siv MySQL hauv Node hauv tsib kauj ruam yooj yim:

  1. Tsim ib qhov project tshiab: mkdir mysql -test && cd mysql -test.
  2. Tsim ib pob. json file: npm init -y.
  3. Nruab tus mysql module: npm nruab mysql .
  4. Tsim ib qho app. js ua ntaub ntawv thiab luam rau hauv cov kab lus hauv qab no (hloov cov chaw tuav raws li qhov tsim nyog).
  5. Khiav cov ntaub ntawv: node app.

Ib yam li ntawd, kuv puas tuaj yeem siv MySQL nrog node js?

Ib zaug koj muaj MySQL nce thiab khiav ntawm koj lub computer, koj ua tau nkag los ntawm siv Node . js . Nkag mus rau a MySQL database nrog Node . js , koj xav tau a MySQL tus tsav tsheb.

Qhov thib ob, peb puas tuaj yeem sau SQL lus nug hauv JavaScript? Txog tam sim no, tib yam tsis ua tau rau Java developers. Txawm li cas los xij, siv JSINQ koj sau tau zoo sib xws SQL lus nug thaum programming hauv JavaScript . Qhov no txhais tau tias koj tam sim no muaj ib nug lus hauv JavaScript uas koj ua tau siv tawm tsam arrays thiab DOM ntawm cov npe.

Ua raws li qhov no hauv kev txiav txim siab, kuv yuav txuas mus rau node js database li cas?

Tutorial: Teeb tsa Node. js nrog database

  1. Nruab Node.js.
  2. Nruab MySQL.
  3. Tsim HTTP API rau kev sau rau hauv cov ntaub ntawv.
  4. Tsim ib co HTML thiab JS rau POST rau API.
  5. Siv Knex migrations los tsim cov neeg siv database schema (ib txoj kev zoo sib xws rau Rails migrations)
  6. Siv kev tsiv teb tsaws chaw los teeb tsa tus password hashing.
  7. Tsim ib txoj hauv kev nkag mus xyuas cov hashing ua haujlwm.

JavaScript puas tuaj yeem sib txuas lus nrog database?

Tsis yog, JavaScript tau tsis ncaj qha txuas rau MySQL as JavaScript yog tus neeg siv sab sau ntawv lus (Exception Node. js ). Koj xav tau ib txheej nruab nrab xws li RESTful API kom nkag tau cov ntaub ntawv. Koj ua tau ntxiv mysql kev twb kev txuas siv PHP ntaub ntawv.

Pom zoo: