首页 \ 问答 \ HHVM MongoDb聚合似乎不起作用(HHVM MongoDb aggregation seems like it doesn't work)

HHVM MongoDb聚合似乎不起作用(HHVM MongoDb aggregation seems like it doesn't work)

我在hhvm上运行了一些php脚本我试图从MongoDB 3.2中的我的集合中获取数值字段的最大值这是我的聚合管道

    $mongo = new \MongoDB\Driver\Manager(MONGODB_HOST);
    $myCollection = new \MongoDB\Collection($mongo, "mydb.mycollection");

    $pipeline = [
            [
                '$group' => [
                    '_id' => 'group_field',
                    'slId' => ['$max' => '$saleId']
                ],
            ]
        ];

    $doc = $myCollection->aggregate($pipeline);

这个管道完全适用于mongo shell,但是从php $ doc包含我的集合中的所有文档,没有$ group应用于它们也许有人可以帮助我吗?


I have some php script running on hhvm I'm trying to get max value of numeric field from my collection in MongoDB 3.2 Here is my aggregation pipeline

    $mongo = new \MongoDB\Driver\Manager(MONGODB_HOST);
    $myCollection = new \MongoDB\Collection($mongo, "mydb.mycollection");

    $pipeline = [
            [
                '$group' => [
                    '_id' => 'group_field',
                    'slId' => ['$max' => '$saleId']
                ],
            ]
        ];

    $doc = $myCollection->aggregate($pipeline);

This pipeline perfectly works in mongo shell, but from php $doc contains all documents from my collection and no $group is applied to them Maybe someone can help me with that?


原文:https://stackoverflow.com/questions/35081494
更新时间:2022-01-28 10:01

最满意答案

使用sudo肯定会工作,你有一个例子在“ post-receive hook permission denied”无法创建文件“error ”,将git命令包装在脚本中。

将收到后更改为:

sudo sh /usr/local/sbin/prgetsimpleappscom

用visudo改变了sudoers

git ALL = (root) NOPASSWD: /bin/sh /usr/local/sbin/prgetsimpleappscom

另一种方法是作为node用户定期提取的cron作业,并且(如果有新的提交)拉入目标仓库。


Using sudo would certainly work, you have one example at "post-receive hook permission denied “unable to create file” error", wrapping the git commands in a script.

Changed post-receive to:

sudo sh /usr/local/sbin/prgetsimpleappscom

Changed sudoers with visudo

git ALL = (root) NOPASSWD: /bin/sh /usr/local/sbin/prgetsimpleappscom

The other approach would be a cron job as node user regularly fetching and (if there are new commit) pulling in the destination repo.

相关问答

更多
  • 尝试使chmod对文件夹的内容而不是文件夹本身进行操作: chmod 755 -R /www/newrails/* 可能发生的事情是钩子正在运行的用户(通常是你用来进行Git访问的用户)有权写入文件夹,但不允许更改文件夹本身的模式。 Try making the chmod operate on the contents of the folder rather than the folder itself: chmod 755 -R /www/newrails/* What's probably ha ...
  • 请检查您的文件是否具有可执行权限。 否则它不能执行。 像rwxr-xr-x应该就足够了。 您可以添加缺少的位 $ chmod +x /path/to/post-receive All of these answers are useful, but it turns out I needed the "bin" directory of git in my PATH variable. I had the "cmd" directory only. Added c:\my_path_to_git\git\ ...
  • 如何添加。 ~git / .profile在你的post-receive钩子脚本的顶部(假设它是sh)。 但是,目前还不清楚你想要什么。 你要么: 1)只是推到外部现场,而不关心回购之间的共性。 在这种情况下,为什么需要来自其他地方的环境变量? 为什么不将最终位置放在post-receive钩子脚本本身? 2)您希望有一些外部变量来控制您将要推送大量不同存储库的根目录,如果您需要更改它,最好将该位置编码为单个变量。 如果是这样的话,你上面所做的事情是有道理的。 但是,你不一定需要首先在.profile中这样 ...
  • 最后,我确实能够通过将目录(/ home / ubuntu / public_html / testing)的所有权更改为提交/运行挂钩的用户来解决它。 At last, I did able to solve it by changing the ownership of the directory(/home/ubuntu/public_html/testing) to the user who is commiting/running hook.
  • 好的问题解决了。 我正在改变小组权限几个小时,它表现得非常奇怪。 后来我意识到你需要注销登录用户才能获得新的权限。 卫生署! :p Ok problem solved. I was changing group permissions for hours and it behaved very strange. Later on I realized that you need to log out en log in the user to get the new permissions working. ...
  • 在接收(服务器端)端单独使用git似乎不可能:你需要自定义你的钩子以便允许这种情况(跳过)发生。 这与本地挂钩不同, 您可以跳过(对于其中一些挂钩) 。 请参阅“ 跳过后接收挂钩中已经处理过的Git修订的处理 ”中的钩子 (这是关于部分提交,但想法类似) It doesn't seem to be possible with git alone on the receiving (server -side) end: you need to customize your hook in order to a ...
  • 2014年更新: Ciro Santilli 在评论和“ 使用GitLab的自定义后接收文件 ”中指出,现在(GitLab不再使用gitolite)是一种设置自定义挂钩的方法 (GitLab 7.5.0 +,2014年11月)。 选择一个需要自定义git钩子的项目。 在GitLab服务器上,导航到项目的存储库目录。 对于手动安装,路径通常是/home/git/repositories//.git 。 对于Omnibus安装,路径通常是/var/opt/gitlab/git-d ...
  • 使用sudo肯定会工作,你有一个例子在“ post-receive hook permission denied”无法创建文件“error ”,将git命令包装在脚本中。 将收到后更改为: sudo sh /usr/local/sbin/prgetsimpleappscom 用visudo改变了sudoers git ALL = (root) NOPASSWD: /bin/sh /usr/local/sbin/prgetsimpleappscom 另一种方法是作为node用户定期提取的cron作业,并且 ...
  • 在文件上,所以它由'git'用户拥有。 我在网络服务器上没有git用户...所有其他git相关文件都归我的用户或root所有。 这是因为oyur webserver是GitLab服务器的客户端。 您引用的文档用于配置GitLab服务器(将后接收挂钩添加到GitLab存储库)。 因此' git '用户,这是GitLab服务器上的默认用户 。 但是如果你要推送到gitlab.com,你就不会直接添加一个钩子。 您需要声明一个Web挂钩 ,然后发送回您可以侦听的JSON消息以触发另一个操作 。 如果你是唯一一个推 ...
  • sudo可能不会保留GIT_WORK_TREE环境变量 - 它经常被配置为为其运行的命令提供已清理的环境,尤其是当它们以root身份运行时。 git有一些命令行参数( --git-dir和--work-tree ),它们完成环境变量的目的。 在这种情况下,您可能需要使用它们。 sudo is likely not preserving the GIT_WORK_TREE environment variable - it is quite often configured to provide a sani ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)