- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我有一个查询,它在一个庞大的集合(超过 48M)中查找数据,但即使我添加 timeout=-1
到它,它仍然会抛出 MongoCursorTimeoutException
异常(exception)..
return \DB::connection('mongodb')->collection('stats')->timeout(-1)
->where('ip','=',$alias)
->where('created_at','>=', new \DateTime( $date ) )
->where('created_at','<=', new \DateTime( $date . ' 23:59:59' ) )
->count();
我正在使用这个库:https://github.com/jenssegers/laravel-mongodb
有什么想法吗?
最佳答案
有一个问题PHP-1249 - MongoCursor::count() should use cursor's socket timeout为 PHP MongoDB 驱动程序 v1.5.7 提交,已于 2014 年 10 月在 v1.5.8 中修复。
reply来自支持:
Looking into the code a bit, it appears that both socket timeout and
maxTimeMS
is not passed along to thecount
command.If you need an immediate work-around, you should be able to get by with
MongoDB::command()
for now (which can support both timeouts).
其中一位用户发布的解决方法是:
$countComand = $mongo->command(
array(
'count' => 'collection',
'query' => $query
),
array('socketTimeoutMS' => -1)
);
if($countComand['ok']){
$count = $countComand['n'];
} else {
// ... error ...
}
看来laravel-mongodb不使用 MongoDB::command()
。您要么必须在没有 where
方法帮助的情况下显式编写查询,如上所示,要么升级到 v.1.5.8。
关于mongodb - jenssegers/laravel-mongodb 中的 MongoCursorTimeoutException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31190504/
我正在尝试使用 Laravel/Jenssegers MongoDB 为我的应用程序设置一些简单的收藏夹 我有两个模型: class Item { public function favori
我试图在我的一个应用程序中实现变音符号不敏感的全词搜索。我写了这个查询并且在 MongoDB 终端中运行良好(我使用了 Robo3T)。 [这里我通过了单词'的Unicode转换艾琳 '] db.ge
我想使用 https://github.com/jenssegers/laravel-mongodb为了使用 laravel 5 连接到 Mongodb,我安装了 MongoDB php 驱动程序,然
我正在使用 jenssegers/laravel-mongodb 开发带有 MongoDB 数据库的 Laravel API . 我正在尝试制作一个过滤器以使用正则表达式获取一些特定数据。在这个插件的
我正在尝试获取 MongoDB 中的用户列表。 _id 为空,无法正确处理。如何使用 MongoDB for Laravel 获取文档的 _id? { "total": 1, "per
我正在使用 jenssegers/laravel-mongodb在 Laravel 中: 我在mongodb中的数据结构如下。假设有 100 行像这样 我需要一个查询来向我显示 finance.sel
这是一个open bug on Github对于 laravel-mongodb 包,但没有任何反应。也许有人知道解决方案..? 选择作为单个文档时,日期显示为日期 { "_id": "5ca
大家好,我是 MongoDB 新手,正在寻找答案 有什么方法可以更新嵌套数组而不循环它。 foreach ($post->comments as $key => $comment) { if ($co
我正在尝试将以下 mongoDB 查询与 Laravel Jessanger 结合使用, 但无法将其作为 raw 查询运行。 db.getCollection('users').aggregate([
我有一个查询,它在一个庞大的集合(超过 48M)中查找数据,但即使我添加 timeout=-1 到它,它仍然会抛出 MongoCursorTimeoutException异常(exception)..
你好,我在我的项目中使用了 laravel、mongoDB 和 AdminLTE 模板。对于 mongoDB,我正在使用 jenssegers/laravel-mongodb。但是现在我在 Larav
我有一个带有 mongodb 的网络应用程序,使用 jenssegers 包。 由于我使用的是 mongodb,是否需要创建任何迁移表?Jenssegers 数据库驱动程序也有(有限)schema b
我有一个名为 changes 的 MongoDB 集合,其中包含以下数据 { "date" : ISODate("2014-06-09T00:00:00.000Z"), "field"
我在使用 Laravel 5.5 和 Jenssegers\Mongodb 关联两个 类 时遇到了麻烦。 这是我的用户类: belongsTo(Login::class, 'login');
我从 Mongodb atlas 开始,我试图将我的 laravel/jenssegers 项目连接到我配置我的 conf/数据库的集群 'mongodb' => [ 'driver' =>
我有以下查询,但它返回一个空数组(我知道这个查询应该返回一条记录这一事实) $created_at = date("Y-m"); $content = ContentModel::where('use
我在项目中使用 jenssegers/laravel-mongodb 库。我有一个集合,其中创建了一个包含其他详细信息的子文档。现在我必须实现一个搜索查询来搜索集合的子文档。子文档是 product_
因此,我设法使用 WSL2 在 Windows 中全新安装了 Laravel。我的项目的需求之一是有两个数据库同时运行mysql和mongodb。 我在我的 docker-compose.yml 中添
我正在尝试将 Eloquent 连接到多个数据库 sqlserver 作为默认连接,而 mongodb 作为辅助连接。我正在使用 jenssegers/laravel-mongodb 使用 compo
我正在使用 MongoDB Laravel 5.3 中的库。我在 MongoDB 中有两个集合,我想建立一个 hasMany 关系 b/w。 MongoDB: 第一个集合:员工 { "_id"
我是一名优秀的程序员,十分优秀!