connectholland/mongo-aggregations 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

connectholland/mongo-aggregations

最新稳定版本:1.3.1

Composer 安装命令:

composer require connectholland/mongo-aggregations

包简介

Library allowing easy access to the mongo aggregate framework

README 文档

README

Build Status StyleCI Latest Stable Version Total Downloads Latest Unstable Version License SensioLabsInsight

MongoAggregations

Library allowing easy access to the mongo aggregate framework

Builders

This library constructs aggregation pipelines using builders. You can add stages (instances of AggregationInterface), collections of stages (AggregationBags) or other builders to construct your pipeline. A special builder is the UnwindBuilder. This Builder will create a pipeline that can unwind both strings and arrays and databases that has the two mixed (the latter should be avoided). Basically the builder will transform any mongo field to an array and then unwind that array.

Example usage of the UnwindBuilder is in its Test: https://github.com/ConnectHolland/MongoAggregations/blob/master/tests/Builder/UnwindBuilderTest.php

Supported stages

This library currently supports the following stages in the aggregate framwork:

Class Operator Description
Match $match https://docs.mongodb.org/manual/reference/operator/aggregation/match/#pipe._S_match
Project $project https://docs.mongodb.org/manual/reference/operator/aggregation/project/#pipe._S_project
Unwind $unwind https://docs.mongodb.org/manual/reference/operator/aggregation/unwind/#pipe._S_unwind
Group $group https://docs.mongodb.org/manual/reference/operator/aggregation/group/#pipe._S_group
Sort $sort https://docs.mongodb.org/manual/reference/operator/aggregation/sort/
RangeProjection A ranged projection stage, a special kind of $project which can map ranges (for example: 1 to 10) to strings (for example to 'low').

Supported operations

Within the stages operations can be used, these are currently supported:

Class Operator Description
Sum $sum https://docs.mongodb.org/manual/reference/operator/aggregation/sum/#grp._S_sum
Condition $cond https://docs.mongodb.org/manual/reference/operator/aggregation/cond/#exp._S_cond
Push $push https://docs.mongodb.org/manual/reference/operator/aggregation/push/#grp._S_push
WeekOperation $week https://docs.mongodb.org/manual/reference/operator/aggregation/week/
FieldOperation Rename a field in a projection (example: {$project: {my_field: {'$some.field.hidden.in.complex.nesting'}}})
ArrayOperation Add an expression in a projection using a mongo array (example: $operation = new ArrayOperation(['$year' => '$somedate']))

EmbeddedCollections

The library adds a class EmbeddedCollection which can be used to create a (temporary) collection that embeds documents that another collection has referenced.

Stages or operations that aren't supported by the library, can still be used by constructing arrays. However, creating a class and the abstraction layer that comes with that is to be preferred.

统计信息

  • 总下载量: 3.24k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 4
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-05