Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

435
Views
Eliminar un solo objeto de matriz en mongodb usando $ unset

https://mongoplayground.net/p/Yv6vkGyrUS-

https://mongoplayground.net/p/vm314GoexjE

 [ { "_id": ObjectId("4b253b067525f35f94b60a31"), "age": 30, "favorite book": [ "Cat's Cradle", "Foundation Trilogy", "Ender's Game" ], "location": "Wisconsin", "name": "joe", "sex": "male" } ]

salida eliminar cualquier elemento con base en la condición

 "favorite book": [ "Cat's Cradle", "Foundation Trilogy" ]
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puedes usar el operador $pull

 db.collection.update({ { _id : id }, { $pull: { "favorite book": "Ender's Game" } } });

Si desea eliminar dos o más elementos de la "lista" de la matriz, también puede hacerlo con el operador $pull:

 db.collection.update({ { _id : id }, { $pull: { "favorite book" : { $in : [ "Foundation Trilogy", "Ender's Game"] } } } });

Consulte ¿Cómo elimino una cadena de una matriz en un documento mongodb?

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!