MongoDB find and remove - the fastest way

前端 未结 4 898
忘掉有多难
忘掉有多难 2021-02-07 13:56

I have a quick question, what is the fast way to grab and delete an object from a mongo collection. Here is the code, I have currently:

$cursor = $coll->find(         


        
4条回答
  •  误落风尘
    2021-02-07 14:16

    I make a new answer to remark the fact:

    As commented by @peterscodeproblems in the accepted answer. The native way to this in mongodb right now is to use the

    findAndModify(query=, remove=True)
    

    As pointed out by the documentation.

    As it is native, and atomic, I expect this to be the faster way to do this.

提交回复
热议问题