• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

232
Views
Cómo eliminar un objeto anidado de un objeto anidado por nombre

Tengo una colección mongodb así. ingrese la descripción de la imagen aquí

Quiero eliminar el objeto con su nombre de equipo y nombre de jugador en mangosta. Así es como lo intenté.

 router.post("/deletePlayer", auth, (req, res) => { const playerName = req.body.playerName; //'ahmet ' const teamName = req.body.teamName;//'Team A' Item.findOneAndRemove( { name: { $players.name: playerName } }, function (err, docs) { if (err) { console.log(err); } else { console.log("Removed User : ", docs); } } ); });
almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

usar update con $pull

 db.collection.update({ name: "Team A" }, { $pull: { player: { name: "c" } } })

parque infantil mongo

almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error