phplaravelmongodbjenssegers-mongodb

mongodb bulk find and remove operation in php


As I wanted to delete a collection that consists approx 50M data(monthly), the normal delete operation was throwing a timeout error even after declaring timeout to -1. the query I am using is $this->where('ts', '>', $start)->where('ts', '<' , $end)->timeout(-1)->delete(). I found bulk.find().remove() operation on mongodb doc which could help but I am unable to find find() method in any of the mongo drivers of php. any suggestions for this?


Solution

  • There is no "find and delete" operation in MongoDB. This is simply a conditional delete.

    For an example using the PHP driver, try this where the $bulk->delete() call is made.