Coder Social home page Coder Social logo

hyperf-mongodb's People

Contributors

yumufeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

hyperf-mongodb's Issues

composer安装问题

我的 hyperf/utils 版本为 v2.1.0,安装的时候提示版本过高,我试过降级都安装不了,求给个解决办法,谢谢

command方法没有兼容$skip(分页问题)

因为一些复杂的分页条件(需要用到$in, $sort,$gte),fetchPagination并不满足我的条件。
我就用command方法操作。
问题:第一页没有问题 条件如下:

[{"$sort":{"_id":-1}},{"$match":{"coupon_id":493,"user_id":{"$in":[1]}}},{"$limit":10},{"$skip":0}]

当我第二页的时候,无法返回数据

[{"$sort":{"_id":-1}},{"$match":{"coupon_id":493,"user_id":{"$in":[1]}}},{"$limit":10},{"$skip":10}]

image

代码截图:

image

MongoDBException.php13mongo数据库连接授权失败:Authentication failed.[50]

        $username = $this->config['username'];
        $password = $this->config['password'];
        if (!empty($username) && !empty($password)) {
            $uri = sprintf(
                'mongodb://%s:%s@%s:%d/%s',
                $username,
                $password,
                $this->config['host'],
                $this->config['port'],
                $this->config['db']
            );
        } else {
            $uri = sprintf(
                'mongodb://%s:%d/%s',
                $this->config['host'],
                $this->config['port'],
                $this->config['db']
            );
        }
        $urlOptions = [];
        //数据集
        $replica = isset($this->config['replica']) ? $this->config['replica'] : null;
        if ($replica) {
            $urlOptions['replicaSet'] = $replica;
        }
        $this->connection = new Manager($uri, $urlOptions);

 $Uri  拼接上db后会链接出错,如果配置文件里面的db 填了admin,  但要查询的数据库别的,这里就出问题了。
 同样的配置文件,在其它框架里面都可以。。。这里应该可以优化下

$this->mongoDb->command只能获取单条记录

public function command(string $namespace, array $filter = [])
{
try {
$command = new Command([
'aggregate' => $namespace,
'pipeline' => $filter,
'cursor' => new \stdClass()
]);
$cursor = $this->connection->executeCommand($this->config['db'], $command);
$count = $cursor->toArray()[0];
} catch (\Exception $e) {
$count = false;
throw new MongoDBException($e->getFile() . $e->getLine() . $e->getMessage());
} finally {
$this->pool->release($this);
return $count;
}
}

$count = $cursor->toArray()[0];

这个转数组后取[0]是有什么原因吗,这样会导致获取的数据不是一个列表

阻塞了协程调度?

看起来只是创建了一个协程版的连接池,连接池里连接的创建/查询等io都运行在协程里,这样会阻塞协程调度吧?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.