Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between 'remove' and 'delete' in MongoDB updates?

I'm studying MongoDB(mongoose).

So I've a question on Model.findByIdAndRemove() and Model.findByIdAndDelete() of Mongoose - what's the difference between both of them.

mongoose-docs

What's the proper use of each?

like image 621
Tomoyoshi Avatar asked Oct 16 '25 04:10

Tomoyoshi


1 Answers

findByIdAndDelete & findByIdAndRemove are same other than findOneAndRemove uses findAndModify with remove functionality with time to execution of particular amount of operations.

by doing comparison findByIdAndDelete is always better than findByIdAndRemove.

like image 149
Parth Raval Avatar answered Oct 17 '25 21:10

Parth Raval



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!