gpt4 book ai didi

mongodb - findOneAndDelete() 和 findOneAndRemove() 的区别

转载 作者:IT老高 更新时间:2023-10-28 13:04:09 27 4
gpt4 key购买 nike

我无法区分 findOneAndDelete()findOneAndRemove()mongoose documentaion .

Query.prototype.findOneAndDelete()

This function differs slightly from Model.findOneAndRemove() in that findOneAndRemove() becomes a MongoDB findAndModify() command, as opposed to a findOneAndDelete() command. For most mongoose use cases, this distinction is purely pedantic. You should use findOneAndDelete() unless you have a good reason not to.

最佳答案

TLDR:您应该使用 findOneAndDelete(),除非您有充分的理由不这样做。


更长的答案:

来自 findOneAndDelete 的 Mongoose 文档:

This function differs slightly from Model.findOneAndRemove() in that findOneAndRemove() becomes a MongoDB findAndModify() command, as opposed to a findOneAndDelete() command. For most mongoose use cases, this distinction is purely pedantic. You should use findOneAndDelete() unless you have a good reason not to.

Mongoose Docs findOneAndDelete

关于mongodb - findOneAndDelete() 和 findOneAndRemove() 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50602037/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com