Cov txheej txheem:

Kuv yuav rho tawm ib cov ntaub ntawv hauv MongoDB li cas?
Kuv yuav rho tawm ib cov ntaub ntawv hauv MongoDB li cas?

Video: Kuv yuav rho tawm ib cov ntaub ntawv hauv MongoDB li cas?

Video: Kuv yuav rho tawm ib cov ntaub ntawv hauv MongoDB li cas?
Video: ua zoo poob peev los lawm tub huas xyooj MV 2023 2024, Kaum ib hlis
Anonim

Yog muaj ntau yam cov ntaub ntawv thiab koj xav tau rho tawm tsuas yog ua ntej sau tseg , ces teem justOne parameter nyob rau hauv tshem tawm () txoj kev. Ntawm no, koj xav tau rho tawm tsuas yog 1. Yog li, teeb "justOne" parameter li 1.

Yog li ntawd, koj yuav rho tawm cov ntaub ntawv hauv MongoDB li cas?

Yog tias koj xav rho tawm ntau cov ntaub ntawv, xav txog kev siv lub plhaub mongo lossis tus tsav tsheb

  1. Luam cov lim hauv qab no rau hauv Compass query bar thiab nyem Nrhiav: { "status": "A" }
  2. Rau txhua daim ntawv, nyem qhov rho tawm icon:
  3. Cov ntaub ntawv yuav yog "Flagged for Deletion", nyem Delete kom paub meej.

Qhov thib ob, kuv yuav ua li cas tshem tawm tag nrho cov ntaub ntawv los ntawm kev sau hauv MongoDB?

  1. Rho tawm tag nrho cov ntaub ntawv. Txhawm rau tshem tawm tag nrho cov ntaub ntawv los ntawm kev sau, hla cov ntaub ntawv lim dej khoob {} mus rau db.
  2. Rho tawm tag nrho cov ntaub ntawv uas phim ib qho xwm txheej. Txhawm rau tshem tawm tag nrho cov ntaub ntawv uas phim cov txheej txheem tshem tawm, hla lub lim dej mus rau db.
  3. Tshem tawm tsuas yog ib daim ntawv uas phim qhov xwm txheej.

Raws li txoj cai, kuv yuav rho tawm ib qho chaw tshwj xeeb hauv MongoDB li cas?

Hauv MongoDB , tus neeg teb xov tooj $unset siv los rho tawm ib qho chaw . Tus nqi teev hauv $unset qhia tsis ua rau muaj kev cuam tshuam rau kev ua haujlwm. Qhov $unset tsis muaj txiaj ntsig thaum lub teb tsis muaj nyob hauv daim ntawv. lub npe kem los yog teb yuav raug tshem tawm.

Kuv yuav tso tseg li cas hauv MongoDB?

MongoDB Delete Collection

  1. Xaiv lub database qhov twg koj sau yog, nrog USE hais kom ua. siv
  2. Tshawb xyuas yog tias cov khoom muaj nyob. qhia collections.
  3. Qhov teeb meem drop() hais kom ua ntawm lub sau.
  4. Yog tias Kev Sau tau raug tshem tawm tiav lawm ces 'muaj tseeb' yog echoed rov qab raws li kev lees paub, lwm tus 'false' yuav tau rov qab.

Pom zoo: