src/League/Monga/Collection.php
public function remove($criteria, $options = [])
    {
        if ($criteria instanceof Closure) {
            $callback = $criteria;

            // Create new Remove query
            $criteria = new Query\Remove();

            // Set the given options
            $criteria->setOptions($options);

            // Execute the callback
            $callback($criteria);
        }

        if ($criteria instanceof Query\Remove) {
            // Retrieve the options, these might
            // have been altered in the closure.
            $options = $criteria->getOptions();

            // Retrieve the where filter
            $criteria = $criteria->getWhere();
        }

        if (! is_array($criteria)) {
            throw new \InvalidArgumentException('Remove criteria must be an array.');
        }

        $maxRetries = $this->maxRetries;
        $tries = 0;

        do {
            try {
                $result = $this->collection->remove($criteria, $options);
                break;
            } catch (MongoCursorException $e) {
                // Retry "save" in case of rediscovery latency issues
                // in replica set failover. Error codes 10107, 13435, and 10058
                // are MongoCursorException's "not master" errors.
                if (in_array($e->getCode(), [10107, 13435, 10058])) {
                    if ($tries === $maxRetries) {
                        throw $e;
                    } else {
                        $tries++;
                        continue;
                    }
                } else {
                    throw $e;
                }
            }
        } while ($tries <= $maxRetries);

        return $result === true || (bool) $result['ok'];
    }
public function remove($criteria, $options = [])
    {
        if ($criteria instanceof Closure) {
            $callback = $criteria;

            // Create new Remove query
            $criteria = new Query\Remove();

            // Set the given options
            $criteria->setOptions($options);

            // Execute the callback
            $callback($criteria);
        }

        if ($criteria instanceof Query\Remove) {
            // Retrieve the options, these might
            // have been altered in the closure.
            $options = $criteria->getOptions();

            // Retrieve the where filter
            $criteria = $criteria->getWhere();
        }

        if (! is_array($criteria)) {
            throw new \InvalidArgumentException('Remove criteria must be an array.');
        }

        $maxRetries = $this->maxRetries;
        $tries = 0;

        do {
            try {
                $result = $this->collection->remove($criteria, $options);
                break;
            } catch (MongoCursorException $e) {
                // Retry "save" in case of rediscovery latency issues
                // in replica set failover. Error codes 10107, 13435, and 10058
                // are MongoCursorException's "not master" errors.
                if (in_array($e->getCode(), [10107, 13435, 10058])) {
                    if ($tries === $maxRetries) {
                        throw $e;
                    } else {
                        $tries++;
                        continue;
                    }
                } else {
                    throw $e;
                }
            }
        } while ($tries <= $maxRetries);

        return $result === true || (bool) $result['ok'];
    }
public function remove ( $ criteria , $ options = [ ] ) { if ( $ criteria instanceof Closure ) { $ callback = $ criteria ; // Create new Remove query $ criteria = new Query \ Remove ( ) ; // Set the given options $ criteria -> setOptions ( $ options ) ; // Execute the callback $ callback ( $ criteria ) ; } if ( $ criteria instanceof Query \ Remove ) { // Retrieve the options, these might // have been altered in the closure. $ options = $ criteria -> getOptions ( ) ; // Retrieve the where filter $ criteria = $ criteria -> getWhere ( ) ; } if ( ! is_array ( $ criteria ) ) { throw new \ InvalidArgumentException ( 'Remove criteria must be an array.' ) ; } $ maxRetries = $ this -> maxRetries ; $ tries = 0 ; do { try { $ result = $ this -> collection -> remove ( $ criteria , $ options ) ; break ; } catch ( MongoCursorException $ e ) { // Retry "save" in case of rediscovery latency issues // in replica set failover. Error codes 10107, 13435, and 10058 // are MongoCursorException's "not master" errors. if ( in_array ( $ e -> getCode ( ) , [ 10107 , 13435 , 10058 ] ) ) { if ( $ tries === $ maxRetries ) { throw $ e ; } else { $ tries ++ ; continue ; } } else { throw $ e ; } } } while ( $ tries <= $ maxRetries ) ; return $ result === true || ( bool ) $ result [ 'ok' ] ; }
Removes documents from the current collection

@param array|Closure $criteria remove filter
@param array         $options  remove options

@return mixed false on failure, number of deleted items on success
Removes documents from the current collection