Tomoyoshi
Tomoyoshi

Reputation: 43

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?

Upvotes: 4

Views: 2884

Answers (1)

Parth Raval
Parth Raval

Reputation: 4443

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.

Upvotes: 5

Related Questions