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
€46.41
List Price:  €64.99
You save:  €18.57
£39.85
List Price:  £55.80
You save:  £15.94
CA$68.38
List Price:  CA$95.74
You save:  CA$27.36
A$75.69
List Price:  A$105.97
You save:  A$30.28
S$67.65
List Price:  S$94.71
You save:  S$27.06
HK$390.96
List Price:  HK$547.38
You save:  HK$156.41
CHF 45.35
List Price:  CHF 63.50
You save:  CHF 18.14
NOK kr542.95
List Price:  NOK kr760.18
You save:  NOK kr217.22
DKK kr346.22
List Price:  DKK kr484.74
You save:  DKK kr138.51
NZ$83.20
List Price:  NZ$116.49
You save:  NZ$33.28
د.إ183.60
List Price:  د.إ257.06
You save:  د.إ73.45
৳5,484.79
List Price:  ৳7,679.15
You save:  ৳2,194.35
₹4,174.22
List Price:  ₹5,844.24
You save:  ₹1,670.02
RM236.85
List Price:  RM331.61
You save:  RM94.76
₦61,737.65
List Price:  ₦86,437.65
You save:  ₦24,700
₨13,903.63
List Price:  ₨19,466.20
You save:  ₨5,562.56
฿1,842.69
List Price:  ฿2,579.91
You save:  ฿737.22
₺1,612.90
List Price:  ₺2,258.19
You save:  ₺645.29
B$253.75
List Price:  B$355.28
You save:  B$101.52
R922.13
List Price:  R1,291.06
You save:  R368.92
Лв90.85
List Price:  Лв127.20
You save:  Лв36.34
₩67,969.88
List Price:  ₩95,163.27
You save:  ₩27,193.39
₪185.94
List Price:  ₪260.34
You save:  ₪74.39
₱2,861.35
List Price:  ₱4,006.12
You save:  ₱1,144.77
¥7,722.34
List Price:  ¥10,811.89
You save:  ¥3,089.55
MX$843.21
List Price:  MX$1,180.56
You save:  MX$337.35
QR182.28
List Price:  QR255.22
You save:  QR72.93
P678.57
List Price:  P950.05
You save:  P271.48
KSh6,648.67
List Price:  KSh9,308.67
You save:  KSh2,660
E£2,385.52
List Price:  E£3,339.92
You save:  E£954.40
ብር2,869.28
List Price:  ብር4,017.22
You save:  ብር1,147.94
Kz41,825.96
List Price:  Kz58,559.69
You save:  Kz16,733.73
CLP$46,485.20
List Price:  CLP$65,083
You save:  CLP$18,597.80
CN¥354.33
List Price:  CN¥496.09
You save:  CN¥141.76
RD$2,899.21
List Price:  RD$4,059.13
You save:  RD$1,159.91
DA6,716.85
List Price:  DA9,404.13
You save:  DA2,687.28
FJ$112.23
List Price:  FJ$157.14
You save:  FJ$44.90
Q388.45
List Price:  Q543.86
You save:  Q155.41
GY$10,455.72
List Price:  GY$14,638.84
You save:  GY$4,183.12
ISK kr6,977.10
List Price:  ISK kr9,768.50
You save:  ISK kr2,791.40
DH500.96
List Price:  DH701.39
You save:  DH200.42
L885.56
List Price:  L1,239.86
You save:  L354.29
ден2,861.59
List Price:  ден4,006.46
You save:  ден1,144.86
MOP$402.29
List Price:  MOP$563.24
You save:  MOP$160.94
N$920.44
List Price:  N$1,288.69
You save:  N$368.25
C$1,839.55
List Price:  C$2,575.52
You save:  C$735.96
रु6,679.37
List Price:  रु9,351.66
You save:  रु2,672.28
S/186.27
List Price:  S/260.79
You save:  S/74.52
K193.32
List Price:  K270.67
You save:  K77.34
SAR187.48
List Price:  SAR262.50
You save:  SAR75.01
ZK1,358.11
List Price:  ZK1,901.47
You save:  ZK543.35
L231.01
List Price:  L323.43
You save:  L92.42
Kč1,161.35
List Price:  Kč1,625.98
You save:  Kč464.63
Ft18,056.25
List Price:  Ft25,280.20
You save:  Ft7,223.94
SEK kr542.25
List Price:  SEK kr759.20
You save:  SEK kr216.94
ARS$44,003.90
List Price:  ARS$61,608.98
You save:  ARS$17,605.08
Bs345.36
List Price:  Bs483.53
You save:  Bs138.17
COP$195,270.45
List Price:  COP$273,394.26
You save:  COP$78,123.80
₡25,568.20
List Price:  ₡35,797.53
You save:  ₡10,229.32
L1,234.61
List Price:  L1,728.55
You save:  L493.94
₲373,712.67
List Price:  ₲523,227.64
You save:  ₲149,514.97
$U1,909.55
List Price:  $U2,673.53
You save:  $U763.97
zł200.30
List Price:  zł280.44
You save:  zł80.13
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.