mongodbmongoosemongodb-queryaggregate-functionscompass

What is the difference between the remove() method and the update() method while remove a field form the documents?


I want to remove a field from the document so let me know I have to use the remove() method or update() method with the $unset operator.


Solution

  • You need update() method with the $unset operator.

    remove() is to delete document.