PHPDaemon\Clients\Mongo\Collection::autoincrement PHP 메소드

autoincrement() 공개 메소드

Generation autoincrement
public autoincrement ( callable $cb, boolean $plain = false ) : void
$cb callable Called when response received
$plain boolean Plain?
리턴 void
    public function autoincrement($cb, $plain = false)
    {
        $e = explode('.', $this->name);
        $col = (isset($e[1]) ? $e[0] . '.' : '') . 'autoincrement';
        $this->pool->{$col}->findAndModify(['query' => ['_id' => isset($e[1]) ? $e[1] : $e[0]], 'update' => ['$inc' => ['seq' => 1]], 'new' => true, 'upsert' => true], $plain ? function ($lastError) use($cb) {
            $cb(isset($lastError['value']['seq']) ? $lastError['value']['seq'] : false);
        } : $cb);
    }