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

363
Views
Tener un problema al eliminar elementos en mongoos usando la función findOneByIdAndRemove()

Estoy resolviendo un reto FREECODECAMP, para pasar este reto necesito eliminar a una persona por su DNI.

el problema es que probé la función sugerida como findByIdAndRemove() y todavía no puedo pasar el desafío y la consola muestra este error:

 (node:9144) [MONGODB DRIVER] Warning: collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead. (Use `node --trace-warnings ...` to show where the warning was created) { _id: new ObjectId("61f2637736f4aea8452a638e"), name: 'Jason Bourne', age: 36, favFood: [], __v: 0 } { _id: new ObjectId("61f2637736f4aea8452a638e"), name: 'Jason Bourne', age: 36, favFood: [], __v: 0, count: 0 }

este es mi código hasta ahora:

 const removeById = function(personID, done) { Person.findByIdAndRemove(personID, (err, IDR) => { if(err) return console.log(err); done(null, IDR); }); };

Gracias de antemano <3

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

FindOneAndRemove está en desuso. Utilice deleteOne

 const user_id = "user_id_to_delete"; await collection.deleteOne({_id: user_id});
about 4 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 Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!