Think/Db/Driver/Mongo.php
public function getMongoNextId($pk)
    {
        if ($this->config['debug']) {
            $this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.find({},{'.$pk.':1}).sort({'.$pk.':-1}).limit(1)';
        }
        try {
            $this->debug(true);
            $result = $this->_collection->find([], [$pk => 1])->sort([$pk => -1])->limit(1);
            $this->debug(false);
        } catch (\MongoCursorException $e) {
            E($e->getMessage());
        }
        $data = $result->getNext();

        return isset($data[$pk]) ? $data[$pk] + 1 : 1;
    }
public function getMongoNextId($pk)
    {
        if ($this->config['debug']) {
            $this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.find({},{'.$pk.':1}).sort({'.$pk.':-1}).limit(1)';
        }
        try {
            $this->debug(true);
            $result = $this->_collection->find([], [$pk => 1])->sort([$pk => -1])->limit(1);
            $this->debug(false);
        } catch (\MongoCursorException $e) {
            E($e->getMessage());
        }
        $data = $result->getNext();

        return isset($data[$pk]) ? $data[$pk] + 1 : 1;
    }
生成下一条记录ID 用于自增非MongoId主键
@param string $pk 主键名
@return int