Mongoose - Delete Many Documents with model.remove()

Mongoose - Delete Many Documents with model.remove()
0

#1

Hi,

Not really sure how to pass this challenge, I feel like, i’ve tried many combinations already

Any guides or examples appreciated

K


#2

Hey @clickingmouse -> Look here:


#3

In console(Status button) is possible to see:
collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.

Instead Person.remove should be Person.deleteMany
In case of error is at the end condition - ternary operator or if statement
whole solution:

var removeManyPeople = function(done) {
  var nameToRemove = "Mary";
  Person.deleteMany({name: nameToRemove}, (err, data)=> {
  err ? done(err) : done(null,data)
}
)};