开发者

remove vs pull vs unset in mongoDB

开发者 https://www.devze.com 2023-03-28 23:00 出处:网络
I can remove a document or an element by remove, pull, unset. What are the dif开发者_如何学Goferences among those three?

I can remove a document or an element by remove, pull, unset.

What are the dif开发者_如何学Goferences among those three?

Which one is safer way to remove in contemporary commanding issue?

and which one is fastest and efficient way to remove?


remove removes a document from the collection. This is like an SQL DELETE.

$pull and $unset are update operations that change part of the document. They are similar to SQL UPDATE.

$pull removes an element from an array.

$unset removes the whole array (or any other field).

and which one is fastest and efficient way to remove?

Since they do completely different things, that is not a meaningful question.

0

精彩评论

暂无评论...
验证码 换一张
取 消