Mongolid\Util\SequenceService::getNextValue PHP 메소드

getNextValue() 공개 메소드

Get next value for the sequence.
public getNextValue ( string $sequenceName ) : integer
$sequenceName string Sequence identifier string.
리턴 integer
    public function getNextValue(string $sequenceName) : int
    {
        $sequenceValue = $this->rawCollection()->findOneAndUpdate(['_id' => $sequenceName], ['$inc' => ['seq' => 1]], ['upsert' => true]);
        if ($sequenceValue) {
            $_id = $sequenceValue->seq + 1;
        }
        return $_id ?? 1;
    }