yii\mongodb\QueryBuilder::buildNotCondition PHP Method

buildNotCondition() public method

Composes NOT condition.
public buildNotCondition ( string $operator, array $operands ) : array
$operator string the operator to use for connecting the given operands
$operands array the Mongo conditions to connect.
return array the generated Mongo condition.
    public function buildNotCondition($operator, $operands)
    {
        if (count($operands) !== 2) {
            throw new InvalidParamException("Operator '{$operator}' requires two operands.");
        }
        list($name, $value) = $operands;
        $result = [];
        if (is_array($value)) {
            $result[$name] = ['$not' => $this->buildCondition($value)];
        } else {
            if ($name == '_id') {
                $value = $this->ensureMongoId($value);
            }
            $result[$name] = ['$ne' => $value];
        }
        return $result;
    }