PHPDaemon\Clients\Mongo\Collection::remove PHP Method

remove() public method

Removes objects from collection
public remove ( array $cond = [], callable $cb = null, array $params = null ) : void
$cond array Conditions
$cb callable Optional. Callback called when response received
$params array Optional. Params
return void
    public function remove($cond = [], $cb = null, $params = null)
    {
        $this->pool->remove($this->name, $cond, $cb);
    }

Usage Example

Example #1
0
 /**
  * @param $names
  * @param callable $cb
  */
 public function check($token, $text, $invalidate = true, $cb)
 {
     $e = static::decodeToken($token);
     if ($e === false) {
         call_user_func($cb, 'badToken');
         return;
     }
     list($id, $rnd) = $e;
     $this->captcha->findOne(function ($t) use($cb, $id, $text, $invalidate) {
         if (!$t) {
             call_user_func($cb, 'expired');
             return;
         }
         Daemon::log(Debug::dump([$invalidate]));
         if (!$invalidate) {
             if (strtolower($t['text']) === strtolower($text)) {
                 call_user_func($cb, 'ok');
                 return;
             }
         }
         $this->captcha->remove(['_id' => new \MongoId($id)], function ($lastError) use($t, $text, $cb) {
             if ($lastError['n'] !== 1) {
                 call_user_func($cb, 'expired');
                 return;
             }
             if (strtolower($t['text']) !== strtolower($text)) {
                 call_user_func($cb, 'incorrect');
                 return;
             }
             call_user_func($cb, 'ok');
         });
     }, ['where' => ['_id' => $id, 'rnd' => $rnd, 'ctime' => ['$gt' => time() - 3600]]]);
 }
All Usage Examples Of PHPDaemon\Clients\Mongo\Collection::remove