Kuv yuav ua li cas thiaj li nres qhov kev sib txuas Sequelized?
Kuv yuav ua li cas thiaj li nres qhov kev sib txuas Sequelized?

Video: Kuv yuav ua li cas thiaj li nres qhov kev sib txuas Sequelized?

Video: Kuv yuav ua li cas thiaj li nres qhov kev sib txuas Sequelized?
Video: YUAV COJ LI CAS TU NEEG KOJ HLUB THIAJ NCO KOJ 2024, Kaum ib hlis
Anonim

Kaw tus kev sib txuas

Sequelize yuav khaws cov kev sib txuas qhib los ntawm lub neej ntawd, thiab siv tib yam kev sib txuas rau tag nrho cov lus nug. Yog koj xav tau kaw tus kev sib txuas , hu sequelize . kaw () (uas yog asynchronous thiab rov qab cog lus)

Tsis tas li nug, qhov txiaj ntsig zoo li cas Sequelize muaj?

Hauv paus Sequelize . js muaj kev txhawb nqa zoo rau cov ntaub ntawv synchronization, mob siab rau kev thauj khoom, koom haum, kev hloov pauv thiab tsiv teb tsaws. Lwm lub ntsiab qhov zoo ntawm Sequelize . js yog nws yooj yim mus kuaj.

Ib yam li ntawd, kuv yuav ua li cas thiaj tsim tau Sequelized database? Nco ntsoov tias koj tau khiav npm nruab -g sequelize-cli !

  1. cd rau hauv ib daim ntawv teev npe nrog Express app.
  2. Khiav npm nruab sequelize pg --save.
  3. Khiav sequelize init.
  4. Kho kom raug config/config.
  5. Tsim cov ntaub ntawv kev loj hlob siv createdb ntawm kab hais kom ua.
  6. Khiav sequelize db: tsiv teb tsaws los kuaj koj qhov kev sib txuas.

Tib neeg kuj nug, Sequelize sync ua dab tsi?

sequelize . synchronization () yuav tsim tag nrho cov ntxhuav hauv cov ntaub ntawv teev tseg. Yog tias koj dhau {force: tseeb} raws li qhov ntsuas rau synchronization method, nws yuav tshem cov ntxhuav ntawm txhua qhov pib thiab tsim cov tshiab. Needless hais, qhov no yog ib qho kev xaiv siv tau tsuas yog rau kev txhim kho.

Sequelize qauv yog dab tsi?

A sequelize qauv sawv cev ib lub rooj nyob rau hauv lub database. Piv txwv ntawm chav kawm no sawv cev ib kab database. Yog tias koj tsis paub nrog cov ntaub ntawv sib txuas xws li SQL, xav tias excel. Ib qho kev sib raug zoo database yog ib lub rooj ntawm kab thiab kab. Sequalize pab tswj lub rooj, muab synchronization, koom haum, validation.

Pom zoo: