Removing documents

MongoDB Fundamentals Updating and deleting
1 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€44.11
List Price:  €61.76
You save:  €17.65
£37.61
List Price:  £52.66
You save:  £15.05
CA$69.13
List Price:  CA$96.78
You save:  CA$27.65
A$77.75
List Price:  A$108.86
You save:  A$31.10
S$64.85
List Price:  S$90.80
You save:  S$25.94
HK$387.44
List Price:  HK$542.45
You save:  HK$155
CHF 41.21
List Price:  CHF 57.70
You save:  CHF 16.49
NOK kr518.61
List Price:  NOK kr726.09
You save:  NOK kr207.48
DKK kr329.19
List Price:  DKK kr460.90
You save:  DKK kr131.70
NZ$84.17
List Price:  NZ$117.85
You save:  NZ$33.67
د.إ183.61
List Price:  د.إ257.07
You save:  د.إ73.46
৳6,093.85
List Price:  ৳8,531.88
You save:  ৳2,438.02
₹4,222.21
List Price:  ₹5,911.44
You save:  ₹1,689.22
RM213.45
List Price:  RM298.85
You save:  RM85.40
₦80,257.94
List Price:  ₦112,367.54
You save:  ₦32,109.60
₨14,092.14
List Price:  ₨19,730.13
You save:  ₨5,637.98
฿1,652.66
List Price:  ฿2,313.86
You save:  ฿661.20
₺1,927.95
List Price:  ₺2,699.29
You save:  ₺771.33
B$286.36
List Price:  B$400.93
You save:  B$114.57
R919.88
List Price:  R1,287.90
You save:  R368.02
Лв86.26
List Price:  Лв120.77
You save:  Лв34.51
₩69,953.15
List Price:  ₩97,940.01
You save:  ₩27,986.85
₪180.40
List Price:  ₪252.58
You save:  ₪72.17
₱2,773.44
List Price:  ₱3,883.04
You save:  ₱1,109.60
¥7,233.22
List Price:  ¥10,127.09
You save:  ¥2,893.87
MX$983.32
List Price:  MX$1,376.73
You save:  MX$393.41
QR182.01
List Price:  QR254.83
You save:  QR72.82
P686.40
List Price:  P961.02
You save:  P274.61
KSh6,473.70
List Price:  KSh9,063.70
You save:  KSh2,590
E£2,538.89
List Price:  E£3,554.65
You save:  E£1,015.76
ብር6,728.99
List Price:  ብር9,421.13
You save:  ብር2,692.13
Kz45,590.88
List Price:  Kz63,830.88
You save:  Kz18,240
CLP$47,378.52
List Price:  CLP$66,333.72
You save:  CLP$18,955.20
CN¥364.67
List Price:  CN¥510.57
You save:  CN¥145.90
RD$2,951.01
List Price:  RD$4,131.65
You save:  RD$1,180.64
DA6,634.45
List Price:  DA9,288.76
You save:  DA2,654.31
FJ$112.82
List Price:  FJ$157.96
You save:  FJ$45.13
Q385.11
List Price:  Q539.19
You save:  Q154.07
GY$10,461.12
List Price:  GY$14,646.40
You save:  GY$4,185.28
ISK kr6,454.20
List Price:  ISK kr9,036.40
You save:  ISK kr2,582.20
DH463.01
List Price:  DH648.26
You save:  DH185.24
L861.52
List Price:  L1,206.21
You save:  L344.68
ден2,713.76
List Price:  ден3,799.49
You save:  ден1,085.72
MOP$400.55
List Price:  MOP$560.81
You save:  MOP$160.25
N$933.50
List Price:  N$1,306.98
You save:  N$373.47
C$1,845.09
List Price:  C$2,583.28
You save:  C$738.18
रु6,780.01
List Price:  रु9,492.56
You save:  रु2,712.54
S/183.84
List Price:  S/257.39
You save:  S/73.55
K204.72
List Price:  K286.62
You save:  K81.90
SAR187.47
List Price:  SAR262.47
You save:  SAR75
ZK1,395.21
List Price:  ZK1,953.40
You save:  ZK558.19
L219.62
List Price:  L307.48
You save:  L87.86
Kč1,098.73
List Price:  Kč1,538.31
You save:  Kč439.57
Ft17,834.90
List Price:  Ft24,970.29
You save:  Ft7,135.39
SEK kr483.27
List Price:  SEK kr676.62
You save:  SEK kr193.34
ARS$58,623.18
List Price:  ARS$82,077.15
You save:  ARS$23,453.96
Bs346.56
List Price:  Bs485.21
You save:  Bs138.65
COP$209,831.60
List Price:  COP$293,781.03
You save:  COP$83,949.42
₡25,326.52
List Price:  ₡35,459.16
You save:  ₡10,132.63
L1,301.19
List Price:  L1,821.77
You save:  L520.58
₲401,593.41
List Price:  ₲562,262.91
You save:  ₲160,669.49
$U2,097.63
List Price:  $U2,936.85
You save:  $U839.22
zł188.56
List Price:  zł264
You save:  zł75.44
Already have an account? Log In

Transcript

Very rarely, we may also have to delete a couple of documents. This can be done by calling the Remove function on a particular collection. For example, if I want to delete a document whose ID is 85, so DB dot products dot find ID is 85. So you can see that it has this data, I can give a command DB dot products dot remove. And the criteria being ID is 85. This actually removes the document once for all, so you won't be able to do an undo operation.

So you should be careful when you're doing this. Delete. We will say the same command again to retrieve the data, we don't have the data so we don't see. Suppose if we give dv dot products dot remove, where brand happens to be fresh. Oh, you can See that it deletes 55 documents. So that means all the documents that match the condition got deleted.

Sometimes if you want only one document to be deleted, which is very unlikely, you can also include just to one as true. So you can say DB dot products dot remove. And then the similar condition brand happens to be Milan. And then I can say just one is true. This actually removes only one, but as you can guess we don't know which one has been deleted.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.